-1

I am managing a server which has multiple cron tasks, one of the crontab entry is like below:

51 ​*/2 *​ * * /root/backup.sh

can anyone explain me what is happening here, at what time the script is running?

I want to run one script 20 minutes every hour, and another script every 20 minutes interval, how will I accomplish it?

Also, I want to run my third cron for 20 or 30 minutes, then it will stop, will resume again next hour, or every two or three hours, run again for 20 minutes, then stop, can I do this?

closed as unclear what you're asking by roaima, jimmij, cuonglm, cas, Archemar Nov 19 '15 at 5:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Assuming you have the cron entry configured to start a new instance every 20 minutes. Do you want each instance to run for a maximum of 20 minutes? Or would you prefer for the job to run to completion, but avoid running another copy of the job while the first is in progress? – roaima Nov 18 '15 at 15:06
  • I want to run the cron for 20 minutes, then it will stop. A new instance will run on the next hour or every two hours. – Manjurul Islam Nov 18 '15 at 15:24
  • 1. cron won't stop your job. You are aware of that, yes? 2. In your question you say you want the job to run every 20 minutes. Here in your comment you say you want it to run every 2 hours. Please decide! – roaima Nov 18 '15 at 15:53
  • I want to run the job for 20 minutes every two hours. Like 12am it will for 20 minutes, then again on 2am for another 20 minutes – Manjurul Islam Nov 18 '15 at 18:05
  • Then please edit your question to say so. At the moment it clearly says, "I want to run the script every 20 minute[s]". – roaima Nov 18 '15 at 20:44
3

You have got here a very comprehensive tutorial.

http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800

In the example you show us, the cron is running every two hours, at minute 51.

For running the script every 20 minutes, you would do

*/20 * * * * /root/backup.sh
  • so that mean the cron is running at 00:51, then next it is running at 2:51, then at 4:51 right? – Manjurul Islam Nov 18 '15 at 14:37
  • how can I make the cron to run for a particular time, then stop, like it will run for 20 minutes, then stop, then will start again on next hour, – Manjurul Islam Nov 18 '15 at 14:44
  • exactly that. Every two hours, same minute. – Rui F Ribeiro Nov 18 '15 at 14:44
  • Please read the tutorial, all explained there. – Rui F Ribeiro Nov 18 '15 at 14:44
  • @ManjurulIslam cron does not care about stopping a job, only starting it. If you need this requirement please edit your question to include this detail. – roaima Nov 18 '15 at 14:56

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