first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
26
shell/tools/crontab-add.sh
Normal file
26
shell/tools/crontab-add.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
## 定时任务
|
||||
if [ $# -le 5 ];then
|
||||
echo -e "\033[32;1m格式错误\033[0m"
|
||||
echo -e "\033[32;1mUSGE:$0 \"x x x x x [script]\"\033[0m"
|
||||
exit 1
|
||||
else
|
||||
read -p "Choose User Execute the task[default root]:" user
|
||||
: ${user:=root}
|
||||
u=`cat /etc/passwd | awk -F ':' '{print $1}' |grep $user`
|
||||
if [ -n $u ];then
|
||||
chattr -i /etc/crontab
|
||||
chattr -i /etc/cron.d/
|
||||
chattr -i /var/spool/cron/
|
||||
|
||||
echo $* >> /var/spool/cron/$user
|
||||
|
||||
chattr +i /etc/crontab
|
||||
chattr +i /etc/cron.d/
|
||||
chattr +i /var/spool/cron/
|
||||
else
|
||||
echo -e "\033[31;1m$user is not exists! \033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue