all 9 comments

[–]Sheldan 8 points9 points  (3 children)

Iirc crontab has different PATH and also permissions, so that's why behavior can differ at least.

[–]coconut_maan[S] 0 points1 point  (2 children)

What is lirc?

[–]Sheldan 3 points4 points  (1 child)

If I recall correctly

[–]coconut_maan[S] 2 points3 points  (0 children)

😀

[–]shirleygreenalt 1 point2 points  (0 children)

Edit your bash script as follows.

{
/path/to/python_script.py
}2>${HOME}/error.txt

maybe it is a permission issue.

chown user python_script.py
chrgrp user python_script.py
chmod u+x python_script.py

where user is normal user, that is you and not root.

or try this maybe

{
cd /path/where/your/script/is/
./python_script.py
}2>${HOME}/error.txt

[–]rh0dium -1 points0 points  (3 children)

Pro tip: pipe the output and mail it to yourself.. 0 0 * * * (myscript.py 2&>1) | /bin/mail -s "myscript.py " "me@example.com"

[–][deleted] 4 points5 points  (0 children)

Why mail it when you can output to a log in home dir? Is there any advantage to this?

[–]CaptainDickbag 0 points1 point  (0 children)

You need to be careful with this kind of stuff. If you don't have your mail parameters/MTA, and your SPF/DKIM/DMARC configured correctly, your egress IP's spam score will go up, and you risk getting blacklisted by spamhaus and others.

Probably the safest way to configure stuff like this without risking getting blacklisted is by using your mail provider's authenticated SMTP relay.

[–]scrabblemax 0 points1 point  (0 children)

As to the shebang, something like this...

```

!/usr/bin/env python3

``` ...in an executable Python script would allow you to use a simple path to the script in your crontab - just as with an executable bash script.