Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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/16.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 如何每小时重新启动一个服务?_Linux_Bash_Shell_Ubuntu_Startup - Fatal编程技术网

Linux 如何每小时重新启动一个服务?

Linux 如何每小时重新启动一个服务?,linux,bash,shell,ubuntu,startup,Linux,Bash,Shell,Ubuntu,Startup,我需要每小时重新启动一次服务。我使用的是Ubuntu12.04LTS,我似乎没有找到一个脚本适合根据前缀时间设置重新启动服务。如何通过脚本自动重新启动服务?通过命令打开crontab: crontab -e 要每60分钟运行一次命令,请执行以下操作: */60 * * * * /path/to/command 将/path/to/command替换为重新启动服务的命令 当您想要重新启动mysql时,它可能是这样的: */60 * * * * service mysqld restart 更

我需要每小时重新启动一次服务。我使用的是Ubuntu12.04LTS,我似乎没有找到一个脚本适合根据前缀时间设置重新启动服务。如何通过脚本自动重新启动服务?

通过命令打开crontab:

crontab -e
要每60分钟运行一次命令,请执行以下操作:

*/60 * * * * /path/to/command
将/path/to/command替换为重新启动服务的命令

当您想要重新启动mysql时,它可能是这样的:

*/60 * * * * service mysqld restart

更多信息可在

中找到,您可以使用Why not fix,这样就不需要重新启动它了?听起来您是在尝试修补某些东西,而不是实际修复您遇到的问题…@whiners-有时您无法花费数周时间调试已损坏服务的代码