Ticket 4829

Summary: no timezone in dates?
Product: Slurm Reporter: Michael DiDomenico <mdidomenico>
Component: User CommandsAssignee: Marshall Garey <marshall>
Status: RESOLVED INVALID QA Contact:
Severity: 4 - Minor Issue    
Priority: ---    
Version: 17.02.7   
Hardware: Linux   
OS: Linux   
Site: IDACCR Alineos Sites: ---
Atos/Eviden Sites: --- Confidential Site: ---
Coreweave sites: --- Cray Sites: ---
DS9 clusters: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Linux Distro: ---
Machine Name: CLE Version:
Version Fixed: Target Release: ---
DevPrio: --- Emory-Cloud Sites: ---

Description Michael DiDomenico 2018-02-23 12:10:34 MST
i sent this to the slurm-users mailing list and then remembered i had support and should have probably opened it here instead...

---

when i run 'scontrol -o -d show job jobid=' i get a long list of variables

some of those variables are spit out as dates.  since the dates do not include a timezone field how should that date field be assumed to work?  from the value i conclude that it's my localtime, but is the date being stored as UTC and  converted using the TIMEZONE env parameter, or are the dates being stored in my current timezone.

My cursory scan of the manpages don't reveal anything related to timezone and date/time's in slurm.  i'm just curious how it works.
Comment 1 Marshall Garey 2018-02-23 14:02:17 MST
Times are stored internally as time_t - the number of seconds since the Epoch (Jan 1 1970 00:00:00 UTC). Slurm converts this time to local time using  the function localtime_r(). If you're curious how it works exactly, check the Slurm function slurm_make_time_str in src/common/parse_time.c.
Comment 2 Michael DiDomenico 2018-02-26 06:38:23 MST
Ok, thanks.  Can you comment on what level of effort would be required to have the dates come out with a timezone or reporting all the dates as epoch time instead?
Comment 4 Marshall Garey 2018-02-26 09:43:51 MST
It's already implemented - use the SLURM_TIME_FORMAT environment variable. From the scontrol man page:

"A valid strftime() format can also be specified."

%s gives seconds since the Epoch; %Z gives the timezone name or abbreviation.

http://man7.org/linux/man-pages/man3/strftime.3.html

$ SLURM_TIME_FORMAT=%s scontrol show job | grep -i time
   RunTime=00:00:00 TimeLimit=UNLIMITED TimeMin=N/A
   SubmitTime=1519663197 EligibleTime=1519663197
   StartTime=1519663197 EndTime=1519663197 Deadline=N/A
   PreemptTime=None SuspendTime=None SecsPreSuspend=0

$ SLURM_TIME_FORMAT=%T%Z scontrol show job | grep -i time   RunTime=00:00:00 TimeLimit=UNLIMITED TimeMin=N/A
   SubmitTime=09:39:57MST EligibleTime=09:39:57MST
   StartTime=09:39:57MST EndTime=09:39:57MST Deadline=N/A
   PreemptTime=None SuspendTime=None SecsPreSuspend=0
Comment 5 Michael DiDomenico 2018-02-26 10:08:17 MST
Thanks, works great.