Epoch time to produce exact date everytime


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Epoch time to produce exact date everytime
# 1  
Old 03-12-2014
Epoch time to produce exact date everytime

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:

Code:
WhatTime=12:30am,daily
date -d@${WhatTime}

Code:
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.
# 2  
Old 03-12-2014
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"
# 3  
Old 03-12-2014
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...
Code:
$
$ 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.
# 4  
Old 03-12-2014
Quote:
Originally Posted by blackrageous
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 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.

Code:
deviceA,12:30am-daily
deviceB,12:00am-Saturday

i'd like to replace the second field with the equivalent epoch time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Second Column Date Into EPOCH Time And Print Complete Row

Hello Team, I am stuck in getting the required output in the following case. Please help. My input file is aa|08/01/2016 bb|08/15/2016 I wish to convert the file into aa|epoch time bb|epoch time I am using following code: (3 Replies)
Discussion started by: angshuman
3 Replies

2. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

3. Shell Programming and Scripting

Convert epoch time to Julian date

Need assistance in converting an epoch time to Julian date To get epoch perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"' (3 Replies)
Discussion started by: ajayram_arya
3 Replies

4. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

5. Programming

Converting a user inputted date to epoch time

Hi all , I need to know how to convert a time stamp entered by the user to be converted to GMT/UTC(epoch time) using mktime() and gmtime() for exapample the input will be put in the form ptm.tm_sec = 0; ptm.tm_min = 59; ptm.tm_hour = 11; ptm.tm_mday = 20;... (2 Replies)
Discussion started by: ada
2 Replies

6. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

7. Shell Programming and Scripting

Convert epoch to human readable date & time format

Hello I have log file from solaris system which has date field converted by Java application using System.currentTimeMillis() function, example is 1280943608380 which equivalent to GMT: Wed, 04 Aug 2010 17:40:08 GMT. Now I need a function in shell script which will convert 1280943608380... (3 Replies)
Discussion started by: Yaminib
3 Replies

8. Shell Programming and Scripting

how to convert date time to epoch time in solaris

Hi, Is there any easy way to convert date time(stored in shell variable ) to epoch time in solaris box? As +%s is working on linux but not on solaris, also -d option is not working. Any suggestion please? (6 Replies)
Discussion started by: anshuman0507
6 Replies

9. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

10. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies
Login or Register to Ask a Question