【发布时间】:2015-01-29 09:20:04
【问题描述】:
将条目插入 /etc/crontab 的首选方法是什么,除非它存在,最好使用单行?
这是我希望放入 /etc/crontab 的示例条目,除非它已经存在于其中。
*/1 * * * * some_user python /mount/share/script.py
我在 CentOS 6.6 上,到目前为止我有这个:
if grep "*/1 * * * * some_user python /mount/share/script.py" /etc/crontab; then echo "Entry already in crontab"; else echo "*/1 * * * * some_user python /mount/share/script.py" >> /etc/crontab; fi
【问题讨论】: