I have a gap in Unix time understanding. Unix time started to be counted on 1/1/1970 but in what timezone?
Say it´s 31st of December 1969 11p.m. in London (-3600 Unix time)
In Sidney they have 8 a.m. 1st of January 1970 (28 800 Unix time) in the same time.
So my question is when did they start counting Unix time? 1/1 1970 of what timezone?
Thank you
"Unix time" should always be UTC.
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_15
Wikipedia has some further verbiage around this at https://en.wikipedia.org/wiki/Unix_time#UTC_basis:
The precise definition of Unix time as an encoding of UTC is only
uncontroversial when applied to the present form of UTC. Fortunately,
the fact that the Unix epoch predates the start of this form of UTC
does not affect its use in this era: the number of days from 1 January
1970 (the Unix epoch) to 1 January 1972 (the start of UTC) is not in
question, and the number of days is all that is significant to Unix
time.
With ISO8601, is there a way to specify a repeating interval which starts at a given time for any day, and repeats over time in that day?
For example, does the following hold:
R2/T09:00:00Z/PT1H = R/2000-01-01T09:00:00/P1D + R/2000-01-01T10:00:00/P1D?
Or is the former not correct under the standard?
The motivation behind this is to run a task at 9am and 10am every day.
No, Iso 8601 cannot irregular repetitions. You would need evaluate/run both of those expressions.
Cron expressions would be a better option as it is widely supported, especially for running tasks. You can find cron expression builders on the web and a library for every language (and OS support with crontab in Unix systems). This expression would handle your use case 0 0 9,10 ? * * * and would run at 9 and 10 am of every day of every year.
Sorry for the response 2 years later.
I'm running into a situation where a cron job I thought was running every 55 minutes is actually running at 55 minutes after the hour and at the top of the hour. Actually, it's not a cron job, but it's a PHP scheduling application that uses cron syntax.
When I ask this application to schedule a job every 55 minutes, it creates a crontab line like the following.
*/55 * * * *
This crontab line ends up not running a job every 55 minutes. Instead a job runs at 55 minutes after the hours, and at the top of the hour. I do not desire this. I've run this though a cron tester, and it verifies the undesired behavior is correct cron behavior.
This leads me to looking up what the / actually means. When I looked at the cron manual I learned the slash indicated "steps", but the manual itself is a little fuzzy on that that means
Step values can be used in conjunction with ranges. Following a range with "<number>" specifies skips of the number's value through the range. For example, "0-23/2" can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is "0,2,4,6,8,10,12,14,16,18,20,22"). Steps are also permitted after an asterisk, so if you want to say "every two hours", just use "*/2".
The manual's description ("specifies skips of the number's value through the range") is a little vague, and the "every two hours" example is a little misleading (which is probably what led to the bug in the application)
So, two questions:
How does the unix cron program use the "step" information (the number after a slash) to decide if it should skip running a job? (modular division? If so, on what? With what conditions deciding a "true" run, and which decisions not? Or is it something else?)
Is it possible to configure a unix cron job to run every "N" minutes?
Step values can be used in conjunction with ranges. Following a range
with "<number>" specifies skips of the number's value through the range. For
example, "0-23/2" can be used in the hours field to specify command
execution every other hour (the alternative in the V7 standard is
"0,2,4,6,8,10,12,14,16,18,20,22"). Steps are also permitted after an
asterisk, so if you want to say "every two hours", just use "*/2".
The "range" being referred to here is the range given before the /, which is a subrange of the range of times for the particular field. The first field specifies minutes within an hour, so */... specifies a range from 0 to 59. A first field of */55 specifies all minutes (within the range 0-55) that are multiples of 55 -- i.e., 0 and 55 minutes after each hour.
Similarly, 0-23/2 or */2 in the second (hours) field specifies all hours (within the range 0-23) that are multiples of 2.
If you specify a range starting other than at 0, the number (say N) after the / specifies every Nth minute/hour/etc starting at the lower bound of the range. For example, 3-23/7 in the second field means every 7th hour starting at 03:00 (03:00, 10:00, 17:00).
This works best when the interval you want happens to divide evenly into the next higher unit of time. For example, you can easily specify an event to occur every 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, or 30 minutes, or every 1, 2, 3, 4, 6, or 12 hours. (Thank the Babylonians for choosing time units with so many nice divisors.)
Unfortunately, cron has no concept of "every 55 minutes" within a time range longer than an hour.
If you want to run a job every 55 minutes (say, at 00:00, 00:55, 01:50, 02:45, etc.), you'll have to do it indirectly. One approach is to schedule a script to run every 5 minutes; the script then checks the current time, and does its work only once every 11 times it's called.
Or you can use multiple lines in your crontab file to run the same job at 00:00, 00:55, 01:50, etc. -- except that a day is not a multiple of 55 minutes. If you don't mind having a longer or shorter interval once a day, week, or month, you can write a program to generate a large crontab with as many entries as you need, all running the same command at a specified time.
I came across this website that is helpful with regard to cron jobs.
https://crontab.guru
And specific to your case with * /55
https://crontab.guru/#*/55_*_*_*_*
It helped to get a better understanding of the concept behind it.
There is another tool named at that should be considered. It can be used instead of cron to achieve what the topic starter wants. As far as I remember, it is pre-installed in OS X but it isn't bundled with some Linux distros like Debian (simply apt install at).
It runs a job at a specific time of day and that time can be calculated using a complex specification. In our case the following can be used:
You can also give times like now + count time-units, where the time-units can be minutes, hours, days, or weeks and you
can tell at to run the job today by suffixing the time with today and to run the job tomorrow by suffixing the time with tomorrow.
The script every2min.sh is executed every 2 minutes. It delays next execution every time the instance is running:
#!/bin/sh
at -f ./every2min.sh now + 2 minutes
echo "$(date +'%F %T') running..." >> /tmp/every2min.log
Which outputs
2019-06-27 14:14:23 running...
2019-06-27 14:16:00 running...
2019-06-27 14:18:00 running...
As at does not know about "seconds" unit, the execution time will be rounded to full minute after the first run. But for a given task (with 55 minutes range) it should not be a big problem.
There also might be security considerations
For both at and batch, commands are read from standard input or the file specified with the -f option and executed. The working directory, the environment (except for the variables BASH_VERSINFO, DISPLAY, EUID, GROUPS, SHELLOPTS, TERM, UID, and _) and the umask are retained from the time of invocation.
This is the easiest way to schedule something to be ran every X minutes I've seen so far.
I have five box jobs a,b,c,d,e. Each box job has a starting condition below.
For job a, the condition is: n(b) and n(c) and n(d) and n(e)
For job b, the condition is: n(a) and n(c) and n(d) and n(e)
For job c, the condition is: n(b) and n(a) and n(d) and n(e)
Similarly for other 2 jobs. (n=not running), These jobs will trigger around 10 minutes apart for every 1 hour. Job "a" starts at 9:00 AM, Job "b" starts at 9:10 AM, Job "c" starts at 9:20 AM and so on.
As per above condition when job "a" running b,c,d,e shouldn't run. But in real time what I am finding is, they are running in parallel. following is the example.
Lets assume job "a" started at 9:00 AM and completed at 9:30 AM, Mean time job "b","c","d" starts as per its schedule at 9:10 AM,9:20 AM & 9:30 AM respectively and waiting for Job "a" to complete. As soon as job "a" complete at 9:30 AM, all jobs "b","c" & "d" starting in parallel since at 9:30 AM (probably for fraction of seconds) no jobs are running so conditions for b,c & d jobs are satisfying and triggering the jobs.
Can some one help me with a solution for above issue.
You can create a box job to include the box jobs b, c and d, including them after one another in the job flow so that the next job cannot run until the previous one has run successfully, ie job c won't run until job b is successful.
Please read: Can I create One Box Job inside another box job in Autosys by JIL where including a box job within a box job is explained
If you do not want them to be reliant on each other then using delayed start times after each job will work, but may not overcome the problem if on an occasion a job takes longer to run and proceeds to run in parallel with one of the other box jobs.
I suggest you can define a resource with single quantity and use the resource in all the 5 jobs. You can even avoid using different start times. This will allow only one job to start at a time.
Scenario
We have a use-case where we need to run a program every minute for some number of hours (let's say 8, but ending on an hour boundary), but we need the program to start running at 6:30am (on the half hour)
I was recently asked if this scenario is possible in a single cronstring, and I can't seem to find a way to do it since the minute area is needed to match both the half hour start time and the execute every minute.
I can see how to do it in two cronstrings, 1 from 6:30am - 7:00am then another from 7:00am-3:00pm
30-59 6 * * * /path/to/my/program.sh
*/1 7-15 * * * /path/to/my/program.sh
Is there anyway to combine these into a single cronstring ?
you can change Time in your PC to 7:00 ot 6:00 when it is 6:30 if it doesn't matters to you