Siduction Forum > Scripting & Kernelhacking

[EN] notification via cron

(1/1)

sunrat:
I am trying to make a regular notification to remind me to get out of the computer chair and have a stretch regularly. This command works as a command or single line bash script:

--- Code: ---kdialog --passivepopup 'Get off your arse' 15
--- End code ---
However running it from cron fails, crontab:

--- Code: ---*/5 * * * * /home/roger/bin/motivation-popup >> /home/roger/motivation.log 2>&1
--- End code ---
Log error:

--- Code: ---Wednesday 19 March  23:15:01 EST 2014
kdialog: cannot connect to X server
--- End code ---
Is there a simple way to modify the script to make it work? It's probably pretty basic but so is my scripting knowledge.

bluelupo:
Hi sunrat,
if you do not have X running on your cronjob will report this error. You have to make sure in your script that runs under that user of this cron job also runs an X session.

sunrat:
Thanks bluelupo. A little more research and I got it work by adding DISPLAY ENV to crontab

--- Code: ---*/15 * * * * env DISPLAY=:0 /home/roger/bin/motivation-popup
--- End code ---

Navigation

[0] Message Index

Go to full version
Powered by Advanced Topic Prefix Pro
Powered by SMFPacks WYSIWYG Editor