knute wrote: ↑Tue Dec 12, 2017 7:06 pm
I'm not sure that */1 is different from * but here nor there.
Correct. It is irrelevant, but see below for further discussion of the idea of running something every minute.
The python interpreter is not in pi's crontab path so it won't run.
False. On any normal Raspbian system (and probably any/all others), both python and python3 are in /usr/bin and, despite all and sundry claims to the contrary that you may see either on these forums or online, /usr/bin is in the default PATH.
Try:
Code: Select all
* * * * * python /usr/local/bin/rsump.py
This can't possibly be an improvement, since either python is in the default PATH (as it most certainly is) or it (i.e., the above command line) won't find it, because no full path to python was given.
In other words, ITYM:
Code: Select all
* * * * * /usr/bin/python /usr/local/bin/rsump.py
but, as noted above, this can't possibly improve things, since /usr/bin is already in the PATH.
But for all that, running things every minute via cron is wrong for about a dozen reasons.
It has to be better to put the delay into your own code, either via Python itself or via a shell script. Since I don't know Python, I'll leave that avenue for others to explore, but I would certainly do it like this:
Code: Select all
#!/bin/bash
while :;do
/usr/local/bin/rsump.py
sleep 60
done
And then run that script instead. Instructions on how to get that script running automatically are beyond the scope of this lesson, but future courses may cover it (if needed).
P.S. If your "sump.py" program might error out (*) - and you would want to stop running it if it does - then you might want to change the above to:
Code: Select all
#!/bin/bash
while /usr/local/bin/rsump.py;do
sleep 60
done
(*) I.e., return a non-zero return code if something went wrong.