Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
601 views
in Technique[技术] by (71.8m points)

Linux crontab 没有效果

请问以下 bash crontab 设定 1 分钟创建一个文件
但一直没有效果

crontab -e
*/1 * * * * name=$(date +"%Y%m%d%H%M%S");name+='.txt';touch /home/test/$name

尝试1 : 查询 log
结果 : 没发现有用的讯息

test@test:~$ grep cron /var/log/syslog
Oct 23 01:17:41 test crontab[7961]: (test) BEGIN EDIT (test)
Oct 23 01:18:33 test crontab[7961]: (test) END EDIT (test)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你这是啥发行版啊? crontab 的执行信息不是应该在 /var/log/cron 或者 /var/log/message里面吗?

另外,不太建议直接在 crontab 里写命令,容易出各种各样的问题(大概是命令转义的问题.),比较建议把你要执行的命令写到一个 shell脚本文件里,脚本运行没问题后,crontab 里直接定时运行这个脚本.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...