I have a shell script to monitor table stats and java apps. It works fine when I run manually. But if I put it in the crontab it will get stuck if I don't redirect it's output with export display
command. Any idea why?
1 Answer
The command should be:
DISPLAY=:1.0 gnome-terminal -x /path/script.sh
Since gnome-terminal is an X application, it uses the DISPLAY
environment variable to connect to the X server and display its windows. To set an environment variable just for the duration of a single command, put the variable assignment at the beginning of the command line.
export DISPLAY
? That sounds like it's an X Windows application, so it needs to know the X server to put the window on.DISPLAY
is normally set when you login to a GUI, and cron isn't in a GUI session.*/2 * * * * export DISPLAY=:1.0 && gnome-terminal -x /path/script.sh