Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart a service each hour?

I have a service I need to restart every hour. I'm using Ubuntu 12.04 LTS and I don't really seem to find a script suitable restarting a service based on a prefixed time setting. How do I restart the service automatically through a script?

like image 380
user1607016 Avatar asked Dec 08 '22 07:12

user1607016


1 Answers

Open crontab by command:

crontab -e

To run a command every 60 minutes:

*/60 * * * * /path/to/command

Replace /path/to/command with command to restart service.

It may look like this when you want to restart mysql:

*/60 * * * * service mysqld restart

More information can be found at http://www.ubuntututorials.com/use-crontab-ubuntu/

like image 143
keeplearningtocode Avatar answered Dec 10 '22 21:12

keeplearningtocode