0

I have a script that creates a cron job to take a backup of a local MongoDB. When I execute crontab -l command, I see following:

* */1 * * * cd /home/user/shell-scripts && sh mongo-backup.sh

I previously configured the same cronjob to run every minute but then I edited it. I have restarted my machine after editing the job.

What am I doing wrong?

Thanks

0
5

use 0 at place of first * like :

0 */1 * * * cd /home/user/shell-scripts && sh mongo-backup.sh

if you use * it means it will execute every minute.

5
  • I am trying your solution. – Darshan Puranik Sep 15 '15 at 5:42
  • Thanks for your speedy answer. Now the job is not running every minute. That's a partial success. – Darshan Puranik Sep 15 '15 at 5:55
  • FYI, Backup scripts executes every hour on dot like 6 then 7 and so on with the solution you suggested. It doesnt execute hour after you create cron job. For example if you create cronjob at 5:27 then first execution will be at 6:00, second execution will be at 7:00 and so on. – Darshan Puranik Sep 15 '15 at 7:08
  • yes , if you want to run every hour on 27 minute then you have to do like : 27 */1 * * * cd /home/user/shell-scripts && sh mongo-backup.sh – pl_rock Sep 15 '15 at 7:37
  • @DarshanPuranik - take a look at some crontab examples and tutorial to better understand it, for example thegeekstuff.com/2009/06/15-practical-crontab-examples (but Google knows much more and there is always man crontab, although it's rather elaborate and long); also, you can just have /home/user/shell-scripts/mongo-backup.sh instead of cd /home/user/shell-scripts && sh mongo-backup.sh – Marek Bettman Sep 15 '15 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.