为什么当我在crontab上使用这一行时,会出现错误?
线:0 1/2 * * * cd public_html/wp-content/plugins && ./16134.bash
错误:errors in crontab file, can't install.
我用http://crontab.guru/帮助创建了这一行,但是它没有工作,我想让crontab在1、3、5、7、9、11、13、15、17、19、21和23小时的第0分钟执行命令。
像这样的行是有用的:0 */2 * * * cd public_html/wp-content/plugins && ./16134.bash
另外,为了替换文件的数据,我使用这个组合,首先清空文件cat/dev/null>16134.txt,其次,在文件中添加py输出./16134.py >> 16134.txt的内容。问题是,当我运行这些命令时,在清空文件后,python的执行大约需要2-5秒,所以这个文件对于2-5秒来说是空白的,这使得我的网站上的输出也是空白的,所以最好有一个替换的替代方案。
感谢您的阅读,任何帮助都将不胜感激。
发布于 2016-08-03 00:39:51
来自man 5 crontab:
Step values can be used in conjunction with ranges. Following a range with
``/<number>'' specifies skips of the number's value through the range. For
example, ``0-23/2'' can be used in the hours field to specify command
execution every other hour (the alternative in the V7 standard is
``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an
asterisk, so if you want to say ``every two hours'', just use ``*/2''.因此,/2必须遵循一系列的值。在您的例子中,您希望在1-23范围内每隔一小时运行一次命令,这样1-23/2就可以工作了。
https://askubuntu.com/questions/806293
复制相似问题