Linux: running a cron job in the foreground

On Linux, is there a way to run a cron job in the foreground (or interactively)? (I have a program that periodically runs to receive user input and does some processing. Therefore, I want to designate it as a cron job that can work in the foreground).

+8
linux cron foreground
source share
3 answers

Try using this for crontab user:

 @hourly DISPLAY=:0 xterm -e /path/to/my/script.sh 

It will open (more often) xterm with your script execution and exit after the script exits. Of course, you must change the @hourly part to suit your needs.

+9
source share

For cron scripting GUI try the following line in the shell :

 crontab -e 

Then in crontab :

 0 7 * * * DISPLAY=:0 /PATH/TO/SCRIPT 
+2
source share

Assuming you are using X, you can always open a window on the selected display.

+1
source share