There is a small python script, with shabang in the beginning.
#!/usr/bin/env python3 The script runs perfectly through bash, but such lines do not work in crontab -e
* * * * * /home/user/script/script.py > /home/user/script/log * * * * * python3 /home/user/script/script.py > /home/user/script/log * * * * * /usr/bin/python /home/user/script/script.py > /home/user/script/log In addition, nothing appears in the log. syslog reports on command execution:
Apr 10 10:58:01 boss-K55DR CRON [4098]: (user) CMD (python3 /home/boss/.backgrounds/bg_changer.py> /home/boss/.backgrounds/bg)
How to force cron to execute a script?
2>&1at the end. 2- Installed scripts should use a fixed address in shebang, for example:/usr/bin/python3. See Should I put #! (shebang) in Python scripts - jfs2>&1at the end of what? What does this sequence do? More precisely, what does&1mean? - aryndin> /.../log 2>&1is the redirection syntax. 1, 2 are file descriptors for stdout, stderr streams respectively (by the way, the shell in cron can also be different if you did not explicitly specifySHELL=/bin/bash. In bash it is easier to redirect both streams to one file:/.../script &> /.../file- jfs2>1enough, an ampersand is needed to get the address of the object, by analogy with C? - aryndin2>1from2>&1in the shell are different, then ask a separate question — this is useful for others (or see an existing question). - jfs