Temperature by email Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
User avatar
Joulinar
Posts: 2068
Joined: Sat Nov 16, 2019 12:49 am

Re: Temperature by email

Post by Joulinar »

hmm can you try the following

Code: Select all

0,5,10,15,20,25,30,35,40,45,50,55 * * * * <your script>
maybe */x notation is not understood correctly

If it still seems to be not working after that, change the command to something like:

Code: Select all

0,5,10,15,20,25,30,35,40,45,50,55 * * * * date >>/tmp/debug_cron_pax.txt
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: Temperature by email

Post by MichaIng »

The */2 notation is interpreted correctly. We use that for implemented minutely timer as well (dietpi-cron > minutely). Have you verified sufficient permissions of the crontab's user to execute the script?

One can also increase cron log level via /etc/default/cron.
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

Joulinar wrote: Fri Feb 07, 2020 4:53 pm

Code: Select all

0,5,10,15,20,25,30,35,40,45,50,55 * * * * date >>/tmp/debug_cron_pax.txt
That was a good hint and, indeed, it works. It's not the notation, */5 ... works, too: the txt file is being created and a new line added every five minutes. So the problems seems to be related to my script somehow. :? What would make a script not being run by cronjob?
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

MichaIng wrote: Fri Feb 07, 2020 5:00 pm One can also increase cron log level via /etc/default/cron.
I'll try that and see what I find ...
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

Ahh, I'm getting closer. The error is not caused by cron but by the mailing program, it trys to send to the wrong email address. But not sure why. When executing the script manually it works, when exectuted by cron the mailer uses different mail settings and hence fails.
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

Heureka ... more or less ;) I have to add "sudo" to the cronjob line to make it work:

Code: Select all

*/2 * * * * sudo bash /usr/local/bin/temp_mon
I only don't understand the reason why it doesn't work without that "sudo".
User avatar
Joulinar
Posts: 2068
Joined: Sat Nov 16, 2019 12:49 am

Re: Temperature by email

Post by Joulinar »

probably it has something to do with the user environment the cron is executed with.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

WarHawk wrote: Fri Feb 07, 2020 4:53 am neat..post it up!
Good idea. Done so here. I'm a Linux novice tho.
Post Reply