T
T
theaidem2014-02-17 23:36:55
Python
theaidem, 2014-02-17 23:36:55

How to run python script with cron?

Hello, there is such a blank:

#!/usr/bin/env python
import pynotify
def sendmessage(title, message):
    pynotify.init("test")
    notice = pynotify.Notification(title, message)
    notice.show()
    return
sendmessage('title', 'body')

Just displays a notifier in ubunt.
Made
chmod +x script.py
./script.py # нотификатор работает

In crontab -e:
*/1 * * * * $HOME/path/to/script.py
But there is no notifier every minute!
I tried to add to the script and in crontab change to:
print 'RUN'
*/1 * * * * $HOME/path/to/script.py >> $HOME/cron.log

And the line RUN appears in cron.log, but there is no notifier one fig
Guys, why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
theaidem, 2014-02-17
@theaidem

Here it is decided:

*/1 * * * * export DISPLAY=:0.0 && export XAUTHORITY=$HOME/.Xauthority && $HOME/path/to/script.py

A
Andrey Burov, 2014-02-17
@BuriK666

*/1 * * * * $HOME/path/to/script.py 2>&1 >> $HOME/cron.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question