Reputation: 3
I want to schedule a cron job in Linux by running a shell script.
The scenario is, I'm taking the time in HH:MM format in the shell script from the user and want to schedule a cron job from the shell script. I even want the cron job to be executed only once.
Thanks in advance...
Upvotes: 0
Views: 924
Reputation: 2654
For the crontab
, you can do something like this:
cur=$(crontab -l)
new="$mm $hh * * * your_command"
echo "$cur$new" | crontab -
For one-shot, crontab is not the good candidate. Use at
(note: your_command must be a file, e.g., a bash script)
at -f your_command $hh:$mm
Upvotes: 1