Search code examples
cron

How to update the crontab and check if its running correctly?


I've modified the crontab with:

sudo crontab -e

and added a cron for a script to run every minute so I can test if it works:

1 * * * * /scripts/backup-script.sh > /scripts/backup-script.logs

Afterwards, I tried to restart the cron service to restart the server but the cron doesn't seem to be working, I tried to use:

crontab -l

and it appears to have the old content as if I didnt even modify it. However, going into crontab -e does show the updated content.


Solution

  • To make your script run every minute your cron record must be:

    * * * * * /scripts/backup-script.sh > /scripts/backup-script.logs
    

    What you enter will run every 1st minute every hour

    And if you add record via crontab command you do not need to touch cron daemon

    To see the cron record you add with sudo crontab -e you must check it with command sudo crontab -l. Otherwise you list cron record of different user