I'm trying to create my first cron job. I'm new to bash scripting too, although I do know some python. I am puzzled by the following:

Here is my cronjob file created with crontab -e:

*/1 * * * * /home/darren/.bash_scripts/urxvt_colors.sh

Contents of urxvt_colors.sh:


python  ~/.Py_Scripts/xr_random_colors.py
xrdb ~/.Xresources

Here is what baffles me. So the python part of the cron job works python ~/.Py_Scripts/xr_random_colors.py is executed every minute. This python script changes the color scheme in my ~/.Xresources file. I confirmed this actually happens by checking every minute. But xrdb ~/.Xresources does not update the file.

Running which python shows /usr/bin/python and which xrdb shows /usr/bin/xrdb. So since they are both executed from /usr/bin, how come only the python script executes?

Also if I run ./urxvt_colors.sh script manually from my terminal then it works as expected, the python script runs and so does xrdb ~/.Xresources

What's happening here?


1 Answer 1


Try to change your script like this


python  ~/.Py_Scripts/xr_random_colors.py && xrdb ~/.Xresources

and i recommend you to use full path to files.

PS maybe you need to define DISPLAY var while exec script

*/1 * * * * DISPLAY=:0 /home/darren/.bash_scripts/urxvt_colors.sh
  • Thanks. Adding DISPLAY=:0 to the cronjob got things working. Reading the "This question already has an answer" link above explained to me why :) Jun 22, 2017 at 22:28

Not the answer you're looking for? Browse other questions tagged .