Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
2
votes
Cron python job not running
similar to yours as I know how to make it:
Create a Python script in user pi's home directory;
$ nano hello.py
Enter a single line in the editor:
print("Hello from Python Script Launched run under cron … To view your "cron user's environment", add the following line to your crontab:
@reboot sleep 10; /usr/bin/printenv > /home/pi/cronenv.txt 2>&1
Review the differences between these two environments …
1
vote
Accepted
YA Cron Question
In the event your program throws an error when run under cron, the following may be useful in capturing any error codes:
/usr/bin/python /home/pi/mediacircus.py > ~/cronjoblog 2>&1
This will redirect … cron has a different set of environment variables than you do when you run as pi. In other words, cron's $PATH is different that pi's.
Hope this helps. …
1
vote
CRON-APT error on host [/etc/cron-apt/config]
I don't use cron-apt (Note), but I would guess that your best move is to deal with this exception for python3-pgzero manually. … It also strikes me as odd that the source code for the cron-apt binary is apparently closed. …
2
votes
Accepted
CRON service shebang
Yes. At least for now you need to specify either python or python3.
At some point, python a.k.a Python ver 2.7.16 may be deprecated, and removed from the Raspbian distribution. But when this will happ …
2
votes
1
answer
1k
views
What is the environment for cron?
When issues arise using cron to schedule events, a frequently-heard explanation is that cron runs with a different set of environment variables than a "normal" user (e.g. pi). … That's all well and good, but what is the environment for the cron user? …
6
votes
Accepted
What is the environment for cron?
We can ask cron to tell us what its environment is. … Note also that the user name (aka LOGNAME iaw System V) isn't cron - it's pi!
If you're not familiar, with your own user environment, it's useful to compare it against the cron environment. …
1
vote
CRON vs While loop
You can figure this out for yourself - you don't need our help. (And you've not given us enough to answer your question anyway!)
You seem to be asking if it is more efficient to use polling, or inter …
2
votes
script runs at terminal - but not in cron
ANSWER:
Running a script from an interactive shell (e.g. bash is the RPi default) is different than running it from cron. … Now consider that same script run from cron. There is no interactive shell, and the script has no way to know what your /dev/pts is - if you even have one!
So what does it do with stdout and stderr? …
1
vote
Cannot run a script after reboot using Cron
Also note that cron defaults to sh (not bash), and that may not work for all the commands in your script. … Second Thing:
Using sudo in your cron jobs works in RPi OS, but it will fail in most distros, and is not "best practice". …
1
vote
Running node script on startup with cron
If you can successfully run your node command from your interactive shell (default bash on RPi OS), then you can also run it in cron under @reboot. … /server.js
At boot time, cron will run sleep for 30 seconds, and then will run node. …
1
vote
GPIO Runtime Error with cron script at reboot
Many of the cron issues reported here have to do with the fact that cron does not monitor availability of resources prior to running an @reboot job. … When this happens, cron simply cannot deal with it, and throws an error that can be misleading. …
2
votes
Troubleshooting cron job to restart broken internet connection
Not sure exactly what's causing the issue, but a couple of things to try:
the cron environment uses sh instead of bash AFAIR. Add SHELL=/bin/bash to crontab just before invoking your script. … You redirect the date output in your script, but the echo output will go to stdout (aka /dev/null in cron env). This approach also loses the stderr output. …
2
votes
Accepted
arecord no such file or directory error when running via cron
By default our cron jobs run in a different environment than (for example) the one in our interactive shell, and the cron environment won't (by default) include the variable XDG_RUNTIME_DIR. … The easiest and best way I've found to do this is to ask cron to tell us! …
1
vote
Accepted
python code to read SMS not working when running under cron
There are several differences between cron, and your shell. … In addition to differences in the PATH environment variable (mentioned elsewhere) that must be addressed, cron can not communicate directly to stdout; in fact, stdout is /dev/null in cron. …
1
vote
Accepted
Restart lxpanel through shell script; works in shell, but not in cron
But let's try to confirm that assumption by asking cron to tell us what its environment actually is. … You should now disable the cron job you added to run printenv. …