Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Temporary Cron Job From the Terminal

Is there a way to create a temporary one-time only cron job from the command line? I'd like to have an egg-timer like function to open a terminal and do:

notify "time is up" 30

which would simply run this after 30 minutes:

zenity --info --text="time is up"

It seems easy enough for me to create, but I'm having a hard time believing no one has created something similar. Searching Ubuntu's repository for timing packages doesn't show anything. Has this been done before?

like image 257
Cerin Avatar asked Dec 05 '22 00:12

Cerin


1 Answers

Use the at command.

$ at now + 30 minutes
at> zenity --info --text="time is up"
at> ^D     (press CTRL-D)

The time format is pretty flexible. Here are a bunch of examples.

$ at 11:45

$ at 0800 Friday

$ at 4pm + 3 days

$ at 9am tomorrow
like image 160
Barry Brown Avatar answered Dec 17 '22 23:12

Barry Brown