1

I would like some help to setup a cron job to run every 10 minutes and stop on next Monday at 00:00:00.

0 0 30 3 * /var/www/html/reports/Test.php

1 Answer 1

0

There is no such facility in cron per se. But you can achieve your goal as explained below. I have not put exact commands - but this is the idea that will work.

  1. Don't place your cron job in a crontab. Place it in /etc/cron.d with a file name like: /etc/cron.d/<your login name>-test-reports.php. Using your login name as part of the script file name reduces the possibility of file name conflicts. Place time specification and the command you want to run in the script. This may need root privileges because /etc/cron.d is rw only to root user.
  2. Figure out the day of next Monday. Say, if it is 30-March-2015 schedule one at script to delete your cron file from /etc/cron.d on the date and time of your interest. You can also determine next Monday's date using command: date --date "next Monday" to avoid hard coding a date in your at script.
1
  • You can use 0 0 3 30 * test -x ./nightly && ./nightly in your own crontab and remove (or chmod -x) nightly with a scheduled at job as outlined above.
    – tripleee
    Mar 29, 2015 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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