You are not logged in.

#1 2013-12-18 19:44:28

leong
Member
Registered: 2013-03-08
Posts: 22

cron that launches X applications on DISPLAY that may vary

Hi,
Alice and Bob both have an X session running, but I cannot know in advance who's using which DISPLAY (eg Alice's can be :3 and Bob's :1 or anything else).
I would like to schedule a cron task that launches an X application (xclock, say) on Alice's DISPLAY, only.
I cannot use the Archwiki trick

17 02 * ... env DISPLAY=:0 /usr/bin/xclock

because the DISPLAY value is unknown

I wrote a bash script /home/alice/clok.sh that stores Alice's DISPLAY in a $DIS variable and issues

DISPLAY=$DIS /bin/xclock

and created a crontab (crontab -u alice -e)

19 20 * * * /bin/bash /home/alice/clok.sh

Everything works fine from the CLI, but cron fails to launch xclock. I got the following log:

déc. 18 20:19:01 CROND[14161]: pam_unix(crond:session): session closed for user alice
déc. 18 20:19:01 CROND[14161]: (alice) CMDOUT (Error: Can't open display: )
déc. 18 20:19:01 CROND[14162]: (alice) CMD (/bin/bash /home/alice/clok.sh)
déc. 18 20:19:01 crond[14161]: pam_unix(crond:session): session opened for user alice by (uid=0)
déc. 18 20:19:01 crond[32400]: (alice) RELOAD (/var/spool/cron/alice)
déc. 18 20:19:01 crond[32400]: (root) CAN'T OPEN (/etc/crontab): no such file or directory

The problem seems to be that cron cannot find the DISPLAY variable.
I have read several posts, including http://askubuntu.com/questions/23009/re … s-not-work but I dont know how to set the proper env variables to be used by cron.

Any idea ?

Offline

Board footer

Powered by FluxBB