Score:0

No Error with Cron but does not work

rw flag

I have written a simple python script that sends notifications using Pushbullet. The command works perfectly in the terminal but does not work automatically. The syslog for Cron:

Nov 29 18:33:01 ubuntu CRON[4255]: (root) CMD (usr/bin/python3 IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)

Nov 29 18:34:01 ubuntu CRON[4266]: (root) CMD (/usr/bin/python3 IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)

Nov 29 18:35:01 ubuntu CRON[4278]: (root) CMD (/usr/bin/python3 IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)

Nov 29 18:36:01 ubuntu CRON[4288]: (root) CMD (usr/bin/python3 /IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)

Nov 29 18:37:01 ubuntu CRON[4297]: (root) CMD (usr/bin/python3 /IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)

Nov 29 18:38:01 ubuntu CRON[4307]: (root) CMD (/usr/bin/python3 /IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1)
hr flag
If you want to know why, I suggest redirecting the output + error streams somewhere other than `/dev/null`
Score:0
cn flag

I guess the problem is enviroment, cause cron does not have full root environment.

02 4 * * * su - root -c '/IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1'

Use this cron entry to get full root environment. This should work.

Score:0
rw flag

problem solved:) I used sudo to open the corntab so the script was extcuted as root I opened the crontab without sudo and added the same line on code

* * * * * python3 IdeaProjects/TradingScript/src/test.py >/dev/null 2>&1

and it worked

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.