0

I'm using a lubuntu desktop, distribution Ubuntu 13.10, i686. This is my problem: in the job list scheduled by cron a job hasn't effect, but in /var/log/syslog its execution is traced. This is the relative log line:

Jun 4 09:06:01 kiosk CRON[14189]: (root) CMD (/usr/bin/xinput set-prop 12 --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 >> /tmp/mybackup.log)

This job should rotate touchscreen mapping.

I try different solutions: I substitute in crontab the with bash -c "", I set "export DISPLAY=:0.0" ("for Graphics related job in Unix Environment we need to set first the DISPLAY...") before the command,...and many other!

I know there are a lots of details affect cron execution (path, environment variables, special character and other) and I have no more idea by now :(

Could some gentleman suggest me an idea? where can I find the problem? Thanks in advance!

2 Answers 2

0

xinput configures and tests X input devices. It uses the $DISPLAY environment variable to find the X server to talk to, so you need to define it, because cron jobs do not require X windows. The easy way is to have the crontab line be

env DISPLAY=:0.0 /usr/bin/xinput set-prop 12 --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 >> /tmp/mybackup.log  

Is there an X server running when the cronjob runs? Also, if there is an X server running, it might be running with the X authentication credentials of a user, and your cron log shows you running as root. If you are not exposed, and are willing to risk reducing your X security, try running

xhost +SI:localhost:root  

on your X server at each login. Or, run the cron job as the same user, not root.

3
  • I tried your advice but I have the same behavior. I confirm that I have an x server running
    – manmando
    Jun 9, 2014 at 10:10
  • Compare the cron environment with the working environment, thusly: $ env | sort >x.environment $ crontab -l # m h dom mon dow command * * * * * env | sort >cron.environment $ sleep 60 $ ls -l {cron,x}.environment -rw-rw-r-- 1 walt walt 112 Jun 8 19:40 cron.environment -rw-rw-r-- 1 walt walt 4216 Jun 8 19:38 x.environment $ diff {cron,x}.environment .......<snip, YMMV>.......`
    – waltinator
    Jun 10, 2014 at 14:53
  • Sorry about the formatting - command lines start with "$"
    – waltinator
    Jun 10, 2014 at 15:00
0

This should be a comment, but I could not format the comment the way I liked.

Compare the cron environment with the working environment, thusly:

$ env | sort >x.environment  
$ crontab -l  
# m h  dom mon dow   command  
*   *  *   *   *     env | sort >cron.environment  
$ sleep 60  
$ ls -l {cron,x}.environment  
-rw-rw-r-- 1 walt walt  112 Jun  8 19:40 cron.environment  
-rw-rw-r-- 1 walt walt 4216 Jun  8 19:38 x.environment  
$ diff {cron,x}.environment  
.......<snip, YMMV>.......  

You must log in to answer this question.

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