That should work, but replace Stock Scanner
with Stock\ Scanner
. You can undo the changes by running crontab -e
and just deleting the line. If you haven't changed EDITOR
and you don't know how to use vi
, you can use EDITOR=nano crontab -e
.
So basically run crontab -e
(or EDITOR=nano crontab -e
) and add a line like this:
30 4 * * 1-5 python ~/PycharmProjects/Stock\ Scanner/stock_scanner.py
The crontab format is described in man 5 crontab
.
Using launchd, you could save a plist like this as ~/Library/LaunchAgents/test.plist
:
<?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>
<string>test</string>
<key>ProgramArguments</key>
<array>
<string>python</string>
<string>/Users/lego90511/PycharmProjects/Stock Scanner/stock_scanner.py</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Weekday</key>
<integer>1</integer>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Weekday</key>
<integer>2</integer>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Weekday</key>
<integer>3</integer>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Weekday</key>
<integer>4</integer>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
<dict>
<key>Weekday</key>
<integer>5</integer>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</array>
</dict>
</plist>
Then load the plist by running launchctl load ~/Library/LaunchAgents/test.plist
or by logging out and back in. You can apply changes to the plist by unloading and loading it.
Note that both cron and launchd use a 24-hour clock. If you meant 4 PM instead of 4 AM, replace the hour values with 16.