1

I´m having some issues with this python script running in cron (Ubuntu), it runs ok without cron:

subprocess.call('/usr/bin/xdotool search --name bla.bla. windowactivate', shell=True)

Cron

4,7,10,15,20 * * * * /usr/bin/python /home/aaa/bbb/ccc.py

In the Cron log i only get "No MTA installed...". Have full paths, cron calls ok the python script (changing the script to a simple "hello world" works ok)...i´m a bit lost.

Edit

Output from cron:

Error: Can't open display: (null)
Segmentation fault (core dumped)

Thanks.

azost
  • 571
  • 11
  • 22
  • Arguably this is a duplicate of http://stackoverflow.com/questions/13593935/cron-python-script-not-executing (and others), or at least I'd suggest starting with them... specifically, can you change the cron entry to do /usr/bin/python /home/aaa/bbb/ccc.py &> /home/aaa/bbb/ccc.out and post ccc.out? – Foon Dec 02 '13 at 03:35
  • There are several questions very similar with mine, tried plenty of solutions, but so far none worked. I´ve edited the question with the output. – azost Dec 02 '13 at 14:35

1 Answers1

1

After following @Foon suggestion to log the output, i found out one solution:

subprocess.Popen('XAUTHORITY=/home/user/.Xauthority DISPLAY=:0 /usr/bin/xdotool search --name bla.bla. windowactivate', shell=True)

Problem Solved!

azost
  • 571
  • 11
  • 22
  • Can you describe your solution and how you came to it? How did you install the cron, etc? – Aki Dec 02 '13 at 15:29
  • My issue is related with XDOTOOL, googling about the log error, bring me up many similar issues, one of them says to add the _XAUT.._ and _DISPLAY.._ . To install cron (Ubuntu, Raspbian), just _sudo crontab -e_ and add the line to the bottom of the crontab. My cron calls a python script which runs at specified minutes (4,7,10,15,20) every hour/day/week/month. In the python script i bring up the window from a software with the name _bla.bla._ then i do other stuff, such as, press keys. – azost Dec 02 '13 at 15:37