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.

2
  • Arguably this is a duplicate of stackoverflow.com/questions/13593935/… (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? Commented Dec 2, 2013 at 3: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. Commented Dec 2, 2013 at 14:35

1 Answer 1

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!

Sign up to request clarification or add additional context in comments.

2 Comments

Can you describe your solution and how you came to it? How did you install the cron, etc?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.