Time setup for different date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Time setup for different date
# 1  
Old 07-12-2016
Time setup for different date

I want to get sleep time in T variable to start my script next day 22:59:59, if start and current date are different I am not able to achieve that(which is giving negative value), so am just adding +23 hours. But if the date are same I can able to get the sleep time, how to get sleep time if the date are different
Code:
if [ $STARTDATE = $CURRENTDATE ]; then \
T=$(date +%M/%D/%Y %I:%M %p  --date="$NOW+ 23 hour")
else 
current=$(date -d --date="22:59:59)
eat=$(date -d --date="$EARLYSTART")
T=`expr $current - $eat`
fi

sleep $T

# 2  
Old 07-12-2016
Having a script sleep for more than 24 hours - although, in principle, technically possible - to me sounds like sth. to avoid. Did you consider cron or at?

Anyway, for assigning T , try (untested!, assuming you use a recent bourne compatible shell like e.g.bash)
Code:
T=$(( $(date -d "00:00:00" +%s) + 172799 - $(date +%s) ))

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to setup command and varaibles one time in a server?

Hi All, Am working on several solaris server and login as root. As soon as access the server as root user, i need to type in below command/set : bash;set -o vi Is there any root profile file i can set this, so that i don't need to keep typing this command as when i access the... (1 Reply)
Discussion started by: Optimus81
1 Replies

2. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

3. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

4. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

5. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

6. UNIX for Dummies Questions & Answers

Setup a cron job and specified the start and end time

Hi guys, How can I specify the start and end time of a cron job. And my start time and end time are specified by minutes. For example, I want to set up a cron runs every 3 minutes from 18:40 to midnight. How can i do this please? Many thanks Best regards, Clu (4 Replies)
Discussion started by: clu
4 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Cron Time Setup

Hi Guys, can someone help me how to setup a job in cron that runs each morning from 8-10 a.m. for every half an hour but starting from 8:50 a.m.? so far i have this: 00,30 8-10 * * * but the problem is that it starts at 8:30 instead of 8:50 Anyone? Thanks! (1 Reply)
Discussion started by: netrom
1 Replies

9. Red Hat

have difficulty with setup red hat first time

I have problem with installation screen of red hat Fedora. I can't bypass the setup screen for RAID controller. My PC has Promise controller. The Redhat boot disk 1 loads the driver when the CD boots in graphic mode. however, the driver screen has no promise driver. I want to skip this step but... (0 Replies)
Discussion started by: sito
0 Replies

10. Solaris

XDMCP setup (only one time)

I tried to connect to a Solaris computer through XDMCP (through Xnest from an RHEL 4u4 computer), but it doesn't quite work. I can login once and everything works perfectly. If I log off and try a 2nd time, I can see the login screen, and can enter the username and password, and then if they are... (0 Replies)
Discussion started by: Claw84
0 Replies
Login or Register to Ask a Question