Linux下的crontab定时执行

一、先来一分手动执行PHP的例子:
cd  /root/
touch  ssh_test. sh
chmod  +x  ssh_test.sh
# vi /root/ssh_test.sh
输入如下内容:
curl http://www.xxx.com/ssh_test.php

二、测试运行
sh  /root/ssh_test.sh

三、使用cron定时任务工具实现自动备份
crontab  -e
添加如下内容(Ctrl+x保存):
(每天凌晨3点运行备份脚本)
0 12 * * * sh /root/ssh_test.sh
(定时任务每10分钟运行一次)
*/10 * * * * sh /root/ssh_test.sh

——————————————-
查看所有用户的crontab任务
以root用户执行
cat /etc/passwd | cut -f 1 -d : |xargs -I {} crontab -l -u {}
查看某个用户的crontab任务
crontab -l -u username

发表评论

邮箱地址不会被公开。 必填项已用*标注