Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 每30分钟运行一次cron作业-使用cron.hourly?_Linux_Bash_Shell_Cron - Fatal编程技术网

Linux 每30分钟运行一次cron作业-使用cron.hourly?

Linux 每30分钟运行一次cron作业-使用cron.hourly?,linux,bash,shell,cron,Linux,Bash,Shell,Cron,我想设置一个cron在我的Linux服务器上每隔半小时运行一个shell脚本 我以前没有设置cron作业,我计划在cron.daily中设置以下内容: */30 * * * * /path/to/my/script 这是否正确?cron.daily不会每30分钟运行一次脚本。您可以通过执行以下操作为您的需求创建一个新的crontab条目 crontab-e 然后添加一行 0,30 * * * * /path/to/script (或) 满足您的要求。您可以通过执行列出所有计划的cronta

我想设置一个
cron
在我的
Linux
服务器上每隔半小时运行一个
shell
脚本

我以前没有设置cron作业,我计划在
cron.daily
中设置以下内容:

*/30 * * * * /path/to/my/script 

这是否正确?

cron.daily
不会每30分钟运行一次脚本。您可以通过执行以下操作为您的需求创建一个新的
crontab
条目

crontab-e

然后添加一行

0,30 * * * * /path/to/script
(或)

满足您的要求。您可以通过执行列出所有计划的
crontab
操作的
crontab-l
来确认您的条目是否已添加到列表中

有一些自定义字符串可用于计划操作,但不适用于30分钟级别

@reboot  #Runs at boot
@yearly  #Runs once a year [0 0 1 1 *]
@annually  #Runs once a year [0 0 1 1 *]
@monthly  #Runs once a month [0 0 1 * *]
@weekly  #Runs once a week [0 0 * * 0]
@daily  #Runs once a day [0 0 * * *]
@midnight  #Runs once a day [0 0 * * *]
@hourly  #Runs once an hour [0 * * * *]
使用上述方法,可以完成如下操作

@hourly /my-path/to/another-script

好的,在我的例子中,我运行的命令如下:crontab-e*/30****/path/to/my/script,这是正确的命令吗?如果没有,请使用我的命令更新答案以运行,thanks@java123999:
crontab-e
打开一个编辑器窗口,在该窗口中应添加新条目。如果您以前添加了它,它还包含其他条目。在那里添加行并保存它。这不是一个完整的命令。好的,我上面评论中的语法对我的命令正确吗?语法是如何每半小时运行一次的?让我们来看看。
@hourly /my-path/to/another-script