LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-22-2014, 01:17 AM   #1
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Rep: Reputation: Disabled
crontab timezone


Hello, friends.
I have a problem with my crontab for root and non-root user.
I created:
0 9 * * * /home/oracle/bin/checktablespace.sh
This script executed in 17:00
I founded:

# hwclock
Wed 22 Jan 2014 03:06:23 PM MSK -0.824326 seconds

# date
Wed Jan 22 11:06:50 MSK 2014

# more /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Etc/GMT+4"
UTC=true
ARC=false

# more /etc/issue
Oracle Linux Server release 5.6
Kernel \r on an \m

How can I set my crontab timezone to server timezone?
 
Old 01-22-2014, 01:56 AM   #2
JJJCR
Member
 
Registered: Apr 2010
Posts: 550

Rep: Reputation: 26
you want to run the cron job at a specific time which is the same as your server timezone?

or you need a script function to convert the timezone?
 
Old 01-22-2014, 02:03 AM   #3
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by JJJCR View Post
you want to run the cron job at a specific time which is the same as your server timezone?

or you need a script function to convert the timezone?
I want ro run all my crontab jobs automatically in my timezone, which is server timezone "Etc/GMT+4".
 
Old 01-22-2014, 03:45 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
I wonder if the time/date is set up correctly on your box.

- Is you hardware clock ("BIOS" time) set to UTC or localtime (MSK / GMT+4)?
If it is set to MSK/GMT+4 than your system clock does not use UTC.

From the info you posted it seems like you have a hardware clock that is set to MSK/GMT+4, but you also told the system that the system clock is set to UTC, which is not correct.

If that is true: Re-run the system-config-date command and select the timezone you are in (Etc/GMT+4 or Europe/Moscow) and make sure that the [ ] System clock uses UTC is not selected (no *)
 
Old 01-22-2014, 03:47 AM   #5
JJJCR
Member
 
Registered: Apr 2010
Posts: 550

Rep: Reputation: 26
check out this link: Sync hardware clock with current system date and time (http://www.linuxweblog.com/node/199)

from above link:
Then sync your hardware clock with the system time.

Quote:
# hwclock --show
# hwclock --systohc -->try this

Last edited by JJJCR; 01-22-2014 at 03:47 AM. Reason: edit
 
1 members found this post helpful.
Old 01-22-2014, 04:36 AM   #6
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
In system-config-date everything is OK.
Command #hwclock --systohc helped me to normalise hwclock time, but crontab works with 8 hours delay.
Problem is something other place.
 
Old 01-22-2014, 04:40 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by applehalf View Post
In system-config-date everything is OK.
Command #hwclock --systohc helped me to normalise hwclock time, but crontab works with 8 hours delay.
Problem is something other place.
Just to make sure: Time and date are shown/used correctly, except when using crontab?
 
Old 01-22-2014, 05:09 AM   #8
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
Time and date are shown correctly. I'm not shure abous "used". So crontab time is wrong.
 
Old 01-22-2014, 05:37 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by applehalf View Post
Time and date are shown correctly. I'm not shure abous "used". So crontab time is wrong.
That is strange. The manual page (man anacron) mentions in the NOTES section that the time-zone needs to be set correctly in order for cron to work correctly.

You mention this in your previous reply:
Quote:
Originally Posted by applehalf
In system-config-date everything is OK.
That doesn't tell us if the BIOS clock is set to UTC or your local time (which seems to be MSK).

- What does your BIOS time show: UTC or localtime?
- Which entries are set in the system-config-date tool?

If this machine only runs Linux than the BIOS time should be set to UTC. If this is a dual boot system (Windows/Linux) the BIOS time should be set to localtime. This, the UTC vs localtime setting, should be reflected in the System clock uses UTC entry.

I do believe you need to reboot your machine if you change the time-zone settings, logging out and in again won't reflect the changes made.

One other thing that comes to mind and which might influence time and date: Is the TZ variable set (echo $TZ)
 
Old 01-22-2014, 05:56 AM   #10
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
In system-config-date:
GMT+4
(MSK is GMT+4)
marked "System clock uses UTC"

My mashine is Linux only.

I have no $TZ

It's the production mushine, so I can't reboot it when I want to do it.
 
Old 01-22-2014, 06:06 AM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by applehalf View Post
In system-config-date:
GMT+4
(MSK is GMT+4)
marked "System clock uses UTC"

My mashine is Linux only.

I have no $TZ

It's the production mushine, so I can't reboot it when I want to do it.
You still haven't answered this: What does your BIOS time show?

All the other things discussed are pointless if you do not answer that one! Everything that is time/date related is based on the BIOS time setting.
 
Old 01-22-2014, 06:47 AM   #12
applehalf
LQ Newbie
 
Registered: Oct 2013
Posts: 20

Original Poster
Rep: Reputation: Disabled
I have:

# clock
Wed 22 Jan 2014 04:48:43 PM MSK -0.196592 seconds
# hwclock
Wed 22 Jan 2014 04:48:45 PM MSK -0.321253 seconds
# date
Wed Jan 22 16:48:46 MSK 2014

and
device bay iLO Date/Time Wed Jan 22 16:47:45 2014
time on basket is 16:50

everything seems to be right.

Last edited by applehalf; 01-22-2014 at 06:50 AM.
 
Old 01-22-2014, 07:21 AM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,899

Rep: Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746
If the cron job actually ran at 1700 vs 0900 then the difference is +6 hours which does not match with a UTC vs local time problem. Was this a typo? In your first post the hardware clock vs system clock were +4 difference which matches your configuration and the hardware (BIOS clock) is set to UTC. However in your last post the hardware clock and date command match.

Does /etc/localtime file exist?
Does the output of the command
zdump -v /etc/localtime | grep 2014

Show info for the MSK timezone?

Last edited by michaelk; 01-22-2014 at 07:23 AM.
 
Old 01-22-2014, 07:39 AM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,202

Rep: Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569Reputation: 569
If you have altered your systems timezone information (and it sounds like you did) you have to restart crond so that it will pick up the new values.
 
1 members found this post helpful.
Old 01-22-2014, 07:43 AM   #15
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by michaelk View Post
If the cron job actually ran at 1700 vs 0900 then the difference is +6 hours which does not match with a UTC vs local time problem.
09:00 -> 17:00 is an 8 hour difference, not 6... Or am I overlooking something?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
DIff B/w Crontab -l & crontab -e Tareq9959 Linux - Newbie 2 05-14-2013 08:27 AM
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 05:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration