-1

I have written a python script named Music_Scrape.py that resides in the following directory /Users/MY_USER_NAME/code/Python_Projects. The script runs with the terminal command /Users/MY_USER_NAME/code/Python_Projects/Music_Scrape.py. I am attempting to have this run every day, but cannot seem to get either cron or launchd to work. I am using OSX El Capitan Version 10.11.6.

Creating the following in CronniX did not work (I attempt to run every minute for debugging purposes).

CronniX attempt

I also attempted to use launchd with the following plist file. This is placed in the ~/Library/LaunchAgents directory. I attempted to launch that with the following commands:

launchctl load ~/Library/LaunchAgents/pullMusic.plist

launchctl start pullMusic

Again nothing happened.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <!-- The label should be the same as the filename without the extension -->
    <string>pullMusic</string>
    <!-- Specify how to run your program here -->
    <key>Program</key>
        <string>/Users/samuelcurtis/code/Python_Projects/Music_Scrape.py</string>
    <!-- Run every minute -->
    <key>StartInterval</key>
    <integer>60</integer><!-- seconds -->
</dict>
</plist>

I have read many posts relating to this issue and have tried using absolute file paths and changing permissions, neither of which seems to have helped. It seems that scheduling a command line command to execute at certain intervals should be a more simple task, but apparently not! What steps would one recommend to debug the issue?

sjc
  • 1

1 Answers1

0

To get the simplest cron GUI for Raspbian, do this:

sudo apt-get install gnome-schedule

It will install it to your menu, and makes it very easy to set up the cron side of things.

For my bash scripts I put them in my ~/scripts directory and it runs them just fine.

If you want to call python programs from your script, you probably know to

chmod +x <filename> 

before it can be run from the command line directly.

Whenever I have had any script issues I always just run it all through manually, beginning from my /home/pi directory.

Then I build my script, including periodic lines like this:

echo "Beginning phase 1" >/home/pi/scripts/test.out
echo date >>/home/pi/scripts/test.out
  and so on

then put it in the scripts directory then use the scheduler to start it running.

By looking at the test.out file you can see any output you have appended from stdout of any commands.

It gives good peace of mind that things are working as you expect.

SDsolar
  • 2,485
  • 3
  • 22
  • 32
  • This doesn't seem to address the question. The issue is not with running the script. As stated in the question, the script runs fine with the command typed manually into the terminal. The problem is that the tools that are supposed to automate this command being entered into the terminal are not functioning as expected, and I am not sure why. Edit: I did use the chmod command to make my python program into an executable script. – sjc Mar 19 '17 at 04:04