0
##find all of folders which beging with ms
##written by zhdya_20171011
find /tmp/msxf -name "ms*" > /tmp/dirlist.txt
for i in `cat /tmp/dirlist.txt`
do
cd $i
touch test.txt
done
##check a file which is c file or not
##written by zhdya_20171011
read -p "pls input a location,like "/tmp/":" l
cd $l
for i in `ls`
do
if [ -c $i ]
then
cp $i /dev/
fi
done
##add a new user group, and let all of new user join in.
##written by zhdya_20171011
read -p "pls input a user's group name, like msxf:" g
read -p "pls input a number which from XX and end of XX, like 01 05, it will create msfinance01 ... msfinance05:" n m
if [ -z $g ] && [ -z $n ] && [ -z $m ]
then
echo "pls it must input the PARA."
exit
fi
groupadd $g
echo "already created the usergroup $g"
for i in `seq $n $m`
do
useradd msfinance$i -g $g
done
echo "already created the user you needs."
##backup all of file and folders in etc. and move to suitable place.
##written by zhdya_20170921
DATE=`date +%Y%m%d`
cd /
tar czvf $DATE_etc.tar.gz etc >/dev/null 2>&1
mv $DATE_etc.tar.gz /root/bak/
echo "already done, pls check it."
再次搞个任务计划即可!
crontab -e
0 0 1 * * /bin/bash /usr/local/sbin/baketc.sh
LINUX_A - 不要在最能吃苦的年龄选择安逸!
1.
#! /bin/bash##find all of folders which beging with ms
##written by zhdya_20171011
find /tmp/msxf -name "ms*" > /tmp/dirlist.txt
for i in `cat /tmp/dirlist.txt`
do
cd $i
touch test.txt
done
2.
#! /bin/bash##check a file which is c file or not
##written by zhdya_20171011
read -p "pls input a location,like "/tmp/":" l
cd $l
for i in `ls`
do
if [ -c $i ]
then
cp $i /dev/
fi
done
3.
#! /bin/bash##add a new user group, and let all of new user join in.
##written by zhdya_20171011
read -p "pls input a user's group name, like msxf:" g
read -p "pls input a number which from XX and end of XX, like 01 05, it will create msfinance01 ... msfinance05:" n m
if [ -z $g ] && [ -z $n ] && [ -z $m ]
then
echo "pls it must input the PARA."
exit
fi
groupadd $g
echo "already created the usergroup $g"
for i in `seq $n $m`
do
useradd msfinance$i -g $g
done
echo "already created the user you needs."
5.
#! /bin/bash##backup all of file and folders in etc. and move to suitable place.
##written by zhdya_20170921
DATE=`date +%Y%m%d`
cd /
tar czvf $DATE_etc.tar.gz etc >/dev/null 2>&1
mv $DATE_etc.tar.gz /root/bak/
echo "already done, pls check it."
再次搞个任务计划即可!
crontab -e
0 0 1 * * /bin/bash /usr/local/sbin/baketc.sh
0
第二题要加一个-a ,我执行了-a 就可以
#! /bin/bash##check a file which is c file or not##written by zhdya_20171011read -p "pls input a location,like "/tmp/":" lcd $lfor i in `ls`do if [ -c $i ] then cp -a $i /dev/ fidone
编辑回复