Is it possible to schedule a crontab edit?
I mean, for example, tomorrow at 10 AM I want to schedule something.
Is there a way to crontab a script that tomorrow will edit crontab (scheduling something)?
I know that this question could seem stupid (in fact obviously I can just schedule in crontab the script now or tomorrow but it is just a curiosity if there is a way to schedule the crontab edit)
Maybe I can just schedule a script calling it CRONTAB_EDIT.sh that will run tomorrow at 9 59 AM something that will edit /var/spool/cron/crontabs and will schedule what I want making me happy.
Any suggestions?
Thanks
71 Answer
You should not edit files in /var/spool/cron/crontabs directly. The correct procedure to do so is:
- get current crontab with the command
crontab -l >file - modify the output file using any means, eg.
sed, perl etc. - apply new crontab with the command
crontab file
If you are doing this for a different user than yourself (you must be root for this of course), add -u username parameter after the crontab command.
You can write a script that performs the above points 1-3 and schedule it using the at command as said in comments.