Search code examples
cron

Created cron job to run every 2 mint


I have configured cron job but it's not working. I wanted to run the myfile.sh script for every 2 mint and below are my configuration in crontab.

# m h  dom mon dow   comman 
2 * * * * /home/ubuntu/myfile.sh

myfile.sh is executable and contains below lines of code

#!/bin/bash
mysqldump -u[user] -p[password] --single-transaction --routines --triggers --all-databases > /home/ubuntu/backup_db10.sql

Is there anywhere we need to add configure anything?


Solution

  • You're running the script at two minutes past every hour. As in 1:02, 2:02 and so on.

    You can change it to something like

    */2 * * * * /home/ubuntu/myfile.sh
    

    to run it every two minutes.

    A bit more info can be found here.