I have a python script, script.py
, and am using cron to run this script periodically. The script runs as expected, but once the cron job finishes, I get the following error in /var/mail/[myusername]:
sh: sysctl Command Not Found
The following is the cron job:
0 14 * * * PATH=$PATH:/usr/sbin PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ /usr/bin/python2.7 ~/.../script.py
I was told to include both PATH and PYTHONPATH in the task (as before, python wouldn't recognize several modules I had imported and had installed), so at this point, I'm not sure what the problem could be
sysctl
is located in/sbin/
instead of/usr/sbin/
. Try adding/sbin
to your PATH variablePATH=PATH="$HOME/sbin/:$PATH" export PATH
And I'm still getting the error... Am I simply not adding PATH correctly?$HOME/sbin/
because$HOME
is/Users/<username>
not the root directory/
. So the short answer is yes, you're not adding PATH correctly.