Bug 960716

Summary: run-crons uses ctime and cmin which makes using touch to set run moment imposible
Product: [openSUSE] openSUSE Distribution Reporter: Forgotten User i-s_0Yd2II <forgotten_i-s_0Yd2II>
Component: BasesystemAssignee: Kristyna Streitova <kstreitova>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Leap 42.1   
Target Milestone: ---   
Hardware: x86-64   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Forgotten User i-s_0Yd2II 2016-01-05 13:39:08 UTC
The run-crons script uses -cmin and -ctime to check if a jobs like the mothley jobs has to be run. 
In the manuals there is the advice to use touch to set a specific day / time for example:

touch -d "$(date -d "3am last month")" /var/spool/cron/lastrun/cron.monthly

This this not work, touch does not modify ctime only atime and mtime.

Sollution:
  let run-crons use atime to check time, or
  just have a setting in /etc/sysconfig/cron like DAILY_TIME
Comment 1 Kristyna Streitova 2016-01-13 14:28:59 UTC
The 'touch' manual pages say:

<snip>
DESCRIPTION    Update the access and modification times of each FILE to the current time.
</snip>

However it's important to say that if you update a mtime (i.e. the file is modified), the ctime is updated too:

$ ls -lc
-rw-r--r-- 1 kstreitova users 6 13. led 12.48 test

$ touch test

$ ls -lc
-rw-r--r-- 1 kstreitova users 6 13. led 12.49 test

As you can see, the 'touch' command changed the ctime of the test file.


So can you please re-check if it really doesn't work? If so, there probably is a different reason.
Comment 2 Kristyna Streitova 2016-01-20 14:55:45 UTC
Alex pointed out via email correctly that I missed the fact that touch -d "$(date -d "3am 1 jan")" doesn't change the ctime to "3am 1 jan" but the ctime is set to today.
 
However SLE12 manual [1] provides a different way how to set the custom times for hourly, daily, weekly and monthly scripts:

<cite>
To run the hourly, daily or other periodic maintenance scripts at
custom times, remove the time stamp files regularly using /etc/crontab
entries (see Example 13.2, “/etc/crontab: Remove Time Stamp Files”,
which removes the hourly one before every full hour, the daily one
once a day at 2:14 a.m., etc.).

EXAMPLE 13.2: /ETC/CRONTAB: REMOVE TIME STAMP FILES REPORT BUG #
59 *  * * *     root  rm -f /var/spool/cron/lastrun/cron.hourly
14 2  * * *     root  rm -f /var/spool/cron/lastrun/cron.daily
29 2  * * 6     root  rm -f /var/spool/cron/lastrun/cron.weekly
44 2  1 * *     root  rm -f /var/spool/cron/lastrun/cron.monthly"
</cite>

In view of this fact I think that there is no need to change our run-crons script. 

Closing as invalid.


[1]
https://www.suse.com/documentation/sled-12/singlehtml/book_sle_admin/book_sle_admin.html#ex.suse.packages.cron.time