当前位置: 技术问答>crontab使用问题?
iis7站长之家
关于crontab的小问题
来源: 互联网 发布时间:2016-02-05
本文导语: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly */...
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
*/5 8-19 * * * root /home/boman/test.sh
上面内容为crontab内容
/home/boman/test.sh内容如下
tar czvf "test`date +%Y%m%d`.tar" /home/boman/testdata
现在情况是单独运行test.sh,可以正常得出结果
但crontab根本不会运行??
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
*/5 8-19 * * * root /home/boman/test.sh
上面内容为crontab内容
/home/boman/test.sh内容如下
tar czvf "test`date +%Y%m%d`.tar" /home/boman/testdata
现在情况是单独运行test.sh,可以正常得出结果
但crontab根本不会运行??
|
路径吧
这样会给你把生成的文件放到/root目录的
这样会给你把生成的文件放到/root目录的
|
*/5 8-19 * * * /home/boman/test.sh
去掉root
去掉root
|
#crontab -u root -e
*/5 8-19 * * * /home/boman/test.sh
这样试试吧
*/5 8-19 * * * /home/boman/test.sh
这样试试吧