Search code examples
linuxbashshellubuntustartup

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?


Solution

  • 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/