cronjob + feh
Hey guys. I wrote a small bash script to use feh to change my background every time its called. I use a cron job to have it execute every 5 minutes.
When I run the script manually it works perfectly, however for some reason when its run via cron it fails. I can see that it is executing but it seems to error for some reason. Any reason why this would happen? Its kind of a drag to have a working script that when run as a cron job suddenly no longer works. Thanks. |
Cron jobs have their own limited environment and their rules. It's difficult to give a clue without seeing the crontab entry and/or the content of the script. By the way, as a normal behavior, the cron daemon sends standard output and standard error of jobs to the crontab owner's mailbox (if they are not explicitly redirected to a file). Have you checked it?
|
Aug 21 18:04:01 drone_x61 cron[3818]: (alphis) RELOAD (crontabs/rage)
Aug 21 18:05:01 drone_x61 cron[19512]: (alphis) CMD (rotate_wallpapers.sh) Aug 21 18:05:22 drone_x61 cron[19511]: (alphis) MAIL (mailed 49 bytes of output but got status 0x0001 this is a piece of the output from /var/log/messages As for mail, I don't even have a mailbox setup. Any ideas? |
Add DISPLAY=:0 before feh
Code:
DISPLAY=:0 few --bg-scale /path/to/image.png |
Ok I redirected output (why didn't I do this before) to a file.
feh ERROR: Can't open X display. It *is* running, yeah? feh ERROR: Can't open X display. It *is* running, yeah? So....I take it cron cannot access my X session? Is there anyway to get around this? I'm beginning to think I'll have to just write the script and have it running in the background constantly if cron cannot do this job. Any thoughts? |
You can try the hint given by Elv13 above. Regarding the mailbox, do you mean the mail command does not exist on your system and you cannot receive system mail?
|
Quote:
The script can look like Code:
#!/bin/bash |
Adding DISPLAY=:0 before feh was just what I needed! Works perfectly now!
Thanks much. If anyone is interested in the BASH script I made for this here it is: Quote:
Edit: to answer your question regarding mail, yes mail is not in my path. I checked dead.letter and got the output /var/log/messages was referring to |
All times are GMT -5. The time now is 05:48 AM. |