I want to be able to configure something like this.
Cron is a job scheduling utility present in Unix like systems. The crond daemon enables cron functionality and runs in background. The cron reads the crontab (cron tables) for running predefined scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
You could try running a cron job @yearly (at 00:00 on New Year's day) which looks at the current year using date(1) and updates the current crontab file to one appropriate for the new year.
Cron job uses the server's define timezone (UTC by default) which you can check by typing the date command in terminal. When you cd into this directory you will see the name of different countries and their timezone. Command to change server timezone.
It can be done in a tricky sort of way.
You need three separate cron
jobs for that range, all running the same code (X
in this case):
"0 7 29,30 6 * X"
)."0 7 * 7-11 * X"
)."0 7 1-30 12 * X"
).This gives you:
# Min Hr DayOfMonth Month DayOfWeek Command
# --- -- ---------- ----- --------- -------
0 7 29,30 6 * X
0 7 * 7-11 * X
0 7 1-30 12 * X
Then make sure you comment them out before June 29, 2010 comes around. You can add a final cron
job on December 31 to email you that it needs to be disabled.
Or you could modify X
to exit immediately if the year isn't 2009.
if [[ "$(date +%Y)" != "2009" ]] ; then
exit
fi
Then it won't matter if you forget to disable the jobs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With