0

as mentionned above, I would like to execute a programme that plays music at certain hour automatically. I tried using crontab but no outcome. This is what I put in crontab:

8 15 30 3 4 python play_music.py

Without the scheduler, the python script is working. I wonder if using crontab is a solution to my problem as crontab might execute the program in its environment.

Does any one have an idea or other solutions? Thanks in advance.

  • 1
    try python /fullpath/to/play_music.py as the cron user will not know where your python script lives. You are correct that running from cron will be in a different environment, check your permissions. – rob Mar 30 '17 at 14:07
1

The path used inside the crontab file can be different form the one defined inside your interactive shell, and many variables are not set at all.

You could add a PATH=$HOME/bin:$PATH line to your crontab file, or just use absolute paths.

PD:If your script uses X11, you should set your $DISPLAY variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.