Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: risshuu on November 29, 2016, 05:16:19 AM

Title: Cron using UTC time?
Post by: risshuu on November 29, 2016, 05:16:19 AM
I was able to fix my RasPi's time by using the timezone file.  When I use the date command, it prints the right time.

However, when I use cron to echo the date command to a file, it uses UTC time.  Why?  Is there a way to fix this?
Title: Re: Cron using UTC time?
Post by: risshuu on November 29, 2016, 07:57:26 AM
Looks like if I use the cron bootcode, it uses UTC time no matter if I use the timezone file or not.  If I stop/start it when booted up, the time cron sees is the local time.
Title: Re: Cron using UTC time?
Post by: Paul_123 on November 29, 2016, 08:56:39 AM
Set your timezone on the commandline.   Look at the TZ  bootcode
Title: Re: Cron using UTC time?
Post by: Greg Erskine on November 29, 2016, 04:13:39 PM
Set your timezone on the commandline.   Look at the TZ  bootcode

Yes that is correct, you need to set both "tz=" and "cron" bootcodes. Check /etc/init.d/tc-config to see how it works.

Here is the crontab file I used to test everything is working OK. The filename, contents and timestamp should match.

Code: [Select]
$ crontab -l -u root

*/1 0 * * * date >> /tmp/crontime0
*/1 1 * * * date >> /tmp/crontime1
*/1 2 * * * date >> /tmp/crontime2
*/1 3 * * * date >> /tmp/crontime3
*/1 4 * * * date >> /tmp/crontime4
*/1 5 * * * date >> /tmp/crontime5
*/1 6 * * * date >> /tmp/crontime6
*/1 7 * * * date >> /tmp/crontime7
*/1 8 * * * date >> /tmp/crontime8
*/1 9 * * * date >> /tmp/crontime9
*/1 10 * * * date >> /tmp/crontime10
*/1 11 * * * date >> /tmp/crontime11
*/1 12 * * * date >> /tmp/crontime12
*/1 13 * * * date >> /tmp/crontime13
*/1 14 * * * date >> /tmp/crontime14
*/1 15 * * * date >> /tmp/crontime15
*/1 16 * * * date >> /tmp/crontime16
*/1 17 * * * date >> /tmp/crontime17
*/1 18 * * * date >> /tmp/crontime18
*/1 19 * * * date >> /tmp/crontime19
*/1 20 * * * date >> /tmp/crontime20
*/1 21 * * * date >> /tmp/crontime21
*/1 22 * * * date >> /tmp/crontime22
*/1 23 * * * date >> /tmp/crontime23
Title: Re: Cron using UTC time?
Post by: risshuu on November 29, 2016, 05:27:54 PM
Thanks!
Title: Re: Cron using UTC time?
Post by: 43str4ng3r on May 28, 2017, 07:05:59 AM
Set your timezone on the commandline.   Look at the TZ  bootcode

Could you please elaborate on how to do this.
I'm amiss...

Thanks for your help.

43S
Title: Re: Cron using UTC time?
Post by: Juanito on May 28, 2017, 07:51:22 AM
see: http://wiki.tinycorelinux.net/wiki:boot_codes_explained
Title: Re: Cron using UTC time?
Post by: polikuo on May 28, 2017, 08:05:14 AM
Also, you might wanna check out:
http://tinycorelinux.net/8.x/x86/tcz/tzdata.tcz.info (http://tinycorelinux.net/8.x/x86/tcz/tzdata.tcz.info)
Title: Re: Cron using UTC time?
Post by: gavinmc42 on May 28, 2017, 08:06:01 AM
I stuck the timezone correction just before the call to the script in crontab.

*/5 * * * * TZ=EST-10 date >> /tmp/date.log
http://forum.tinycorelinux.net/index.php/topic,17638.msg106134.html#msg106134
Title: Re: Cron using UTC time?
Post by: 43str4ng3r on May 29, 2017, 01:26:34 PM
Problem solved.

Thanks for your help.  ;)

43S