Reputation: 64739
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?
Upvotes: 5
Views: 5339
Reputation: 360105
If you know that your $DISPLAY
will be the same, you can do:
echo "DISPLAY=$DISPLAY zenity --info --text=\"time is up\"" | at now + 30 minutes
Providing the environment variable in this way will make it available to zenity
when it's run.
Upvotes: 5
Reputation: 20604
You could write yourself a little script.
#! /bin/bash
sleep $(($2 * 60))
zenity --info --text="$1"
Make it executable and run it from the command line:
./notify "Time is up" 30
Upvotes: 2
Reputation: 20604
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
Upvotes: 9