How to make a Daily Cron only for a month? I want to run a certain command everyday at 2PM but want to run It only for a month, and after the month it should stop on its own. How to make it?

  • Have you tried anything or getting any error. show us the error. – Mongrel Nov 9 '16 at 7:05

Create a file e.g. /etc/cron.d/onlyfor1month

Put this into that file:

0 14  * 12 * root /this/is/run/everydayofthemonth/at2pm
0 15 31 12 * root rm -f /etc/cron.d/onlyfor1month

The first line runs the job every day in December at 2pm, as root (change the root if it should be run as another user). The second line runs on the 31st of December at 3pm (also as root, this must be root) and removes the cron file, so that it won't cause the job to be run again next December.

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.