so i have to perform a certain task at set times. for instance, i need to run a job at 12:30am every night, and other jobs, i only need to have them run on saturdays.
how do i manipulate the date command to give me the epoch equivalence of what 12:30am would be every day?
im looking for a simple command that can just output to me what the epoch time would be.
something along the lines of:
WhatTime=12:30am,daily
date -d@${WhatTime}
WhatTimeDay=12:00am,Saturday
date -d@${WhatTimeDay}
The goal here is to submit the epoch time produced by the above command to a program and the program will know to run the job at the time specified, whether it be daily or on specific days.
This is to run on a Linux or SunOS box.
please advise.
Have you consider just using cron.
I am also not clear on what you mean by "epoch time". A lot of computer time mechanisms are based on "seconds since epoch"
I agree, just use cron. You want to run a jon at 12:30 every night? Just put it in crontab.
Anyway, each 12:30am is a different epoch second every night. The epoch started as midnight Jan 1, 1970 and has been incrementing ever since. The Linux date command can do what you asked...
$
$ date --date "1/1/1970 00:00:00" +%s
18000
$ date -u --date "1/1/1970 00:00:00" +%s
0
$
I had to use -u to get GMT time.
i am using cron. but based on how things are set up, there's several devices i need to perform a function on and each device has different times the job has to run on them.
epochtime is basically the equivalence of a changing date.
for instance, if i have to run a job on deviceA at 12:30am every day and on deviceB every Saturday at 12:00am, how do i get the epoch time of that?
deviceA is just one of many devices in a file.
deviceA,12:30am-daily
deviceB,12:00am-Saturday
i'd like to replace the second field with the equivalent epoch time.