Creating a temporary cron job from terminal

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

notify "time is up" 30

which would just start this after 30 minutes:

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

It seems to me that it’s easy for me to create, but it’s hard for me to believe that no one has created something like this. Searching the Ubuntu repository for synchronization packages does not show anything. Has this been done before?

+3
source share
4 answers

If you know yours $DISPLAYwill be the same, you can do:

echo "DISPLAY=$DISPLAY zenity --info --text=\"time is up\"" | at now + 30 minutes

Providing an environment variable in this way will make it available zenitywhen it starts.

+4

at.

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

. .

$ at 11:45

$ at 0800 Friday

$ at 4pm + 3 days

$ at 9am tomorrow
+9

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
+2
source

Source: https://habr.com/ru/post/1774834/


All Articles