Schedule a crontab edit

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

7

1 Answer

You should not edit files in /var/spool/cron/crontabs directly. The correct procedure to do so is:

  1. get current crontab with the command crontab -l >file
  2. modify the output file using any means, eg. sed, perl etc.
  3. 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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like