Bash script and Crontab
There is one thing I want to take note about running a bash script with crontab:
If I use the bash script alone, this will work:
$ /path/to/my/script.sh
#! /bin/bash
export DISPLAY=:0
/path/to/my/pythonGUIapp.py &
But if I run script.sh with crontab, It will not work:
$ sudo crontab -u trinh -e
5 5 * * * /path/to/my/script.sh
To make it work, I have to change directory to the pythonGUIapp.py before executing it. So, change the script.sh as below:
#! /bin/bash
export DISPLAY=:0
cd /path/to/my/
./pythonGUIapp.py &
If I use the bash script alone, this will work:
$ /path/to/my/script.sh
#! /bin/bash
export DISPLAY=:0
/path/to/my/pythonGUIapp.py &
But if I run script.sh with crontab, It will not work:
$ sudo crontab -u trinh -e
5 5 * * * /path/to/my/script.sh
To make it work, I have to change directory to the pythonGUIapp.py before executing it. So, change the script.sh as below:
#! /bin/bash
export DISPLAY=:0
cd /path/to/my/
./pythonGUIapp.py &
Comments
Post a Comment