Sponsored Content
Full Discussion: adding time
Top Forums UNIX for Dummies Questions & Answers adding time Post 302136587 by nickg on Tuesday 18th of September 2007 04:19:30 PM
Old 09-18-2007
adding time

I want to write a little script that will add 24:00 to the current time if the current time is in between 00:00 and 05:00. I want to make this new time a brand new file so I can work with it. I am not sure how to do this.




variable = current time on our system ( I will pull this)

example:

if (variable) is in between 00:00 and 05:00
then
(variable) + 24:00 = newfile


an example might look like this :

if the time I pull is 00:25 then add 00:25 to 24:00 and get 24:25 and put the 24:25 in a brand new file.

Thanks,

ngg
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding Elapsed time

I'm using the Bourne shell and trying to write a script that will add all the time that any particular user has been on the network for. I've used last-h | grep "username" | cut -c 58-62 to get the times. Then I wrote a script that takes the time and converts it into just minutes. Now I... (1 Reply)
Discussion started by: jrdnoland1
1 Replies

2. UNIX for Advanced & Expert Users

Adding # minutes to current time...

Hi all, Looking for a way to add lets say 10 minutes to the current time output should look like 7:15 AM or 7:15 PM. I know that gdate could do this for me but unfortunately its not available on the system I'm working on. So if any one know any way I can accomplish this using the date command it... (7 Replies)
Discussion started by: gptavares
7 Replies

3. UNIX for Dummies Questions & Answers

adding time server

Hello Everybody, I have sun machine running Sol9 with ntpq running on it, and I have a network time server, I want to synchronize my sun machine with that time server, is there any way I can add the time server to my sun machine, root@yuda> ntpq ntpq> peers localhost: timed out, nothing... (4 Replies)
Discussion started by: aladdin
4 Replies

4. Shell Programming and Scripting

change the filename by adding up 1 each time, tricky one

:confused: Hi, I posted here before for adding up of datafile name each time, here is an example: #!/bin/bash cutdfname="data11.dbf" newname=$(echo "${cutdfname}" |tr "" "" |tr "#_@-" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" |tr -s "x") num=$(echo $newname |cut -d"." -f1|awk... (5 Replies)
Discussion started by: netbanker
5 Replies

5. Shell Programming and Scripting

problem with displaying date and adding time

Hi, I have a log file with contents like 81.49.74.131 - - 81.49.74.131 - - 116.112.52.31 - - 116.112.52.31 - - I need an output like this 81.49.74.131 14/Sep/2008 Time duration: 00:06:00 116.112.52.31 15/Sep/2008 Time duration: 00:00:01 Please anyone suggest a script for this.... (1 Reply)
Discussion started by: FuncMx
1 Replies

6. Shell Programming and Scripting

Adding date and time to file name

Hi All, i wanted to add date and time to the file names in the same directory so lets say a file in the directory is test.txt then after running the shell script it should be test-15-11-2010.txt. So I used the following script which works, #!/bin/bash thetime=`date +%Y-%m-%d--%H:%M:%S`... (7 Replies)
Discussion started by: cc_at_work
7 Replies

7. Shell Programming and Scripting

Adding columns of time

Hello all, I'm in the process of writing a script, and I need to be able to add columns of time in the following format (time elapsed Net Backup logs): 000:01:03 000:00:58 000:00:49 Does anyone have a way of converting and/or adding timestamps such as these accurately? Thanks in... (9 Replies)
Discussion started by: LinuxRacr
9 Replies

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

9. Shell Programming and Scripting

Adding Seconds to UNIX/Epoch-Time

Hello All, I have a Perl script I'm writing where I ask the user to enter a "start time" for something. The "$start_time" will be in the format of: # The Time CLI Option Can be in the format of: --start-time="1day" --start-time="2hours" --start-time="45min" ... (1 Reply)
Discussion started by: mrm5102
1 Replies

10. UNIX for Advanced & Expert Users

Help with adding a new driver in initrd at install time

I have a really old distro (FC7) that I am trying to make compatible with some new hardware (ie. new RAID drivers)... I put the RAID driver into the ISO so that the installer can detect the RAID set... but post-install (aka: first boot) it appears that the Anaconda-generated initrd does not have... (0 Replies)
Discussion started by: jjinno
0 Replies
PTHREAD_COND_TIMEDWAIT(3)				   BSD Library Functions Manual 				 PTHREAD_COND_TIMEDWAIT(3)

NAME
pthread_cond_timedwait -- wait on a condition variable for a specific amount of time SYNOPSIS
#include <pthread.h> int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); DESCRIPTION
The pthread_cond_timedwait() function atomically blocks the current thread waiting on the condition variable specified by cond, and releases the mutex specified by mutex. The waiting thread unblocks only after another thread calls pthread_cond_signal(3), or pthread_cond_broadcast(3) with the same condition variable, or if the system time reaches the time specified in abstime, and the current thread reacquires the lock on mutex. Values for struct timespec can be obtained by adding the required time interval to the the current time obtained using gettimeofday(2). Note that struct timeval and struct timespec use different units to specify the time. Hence, the user should always take care to perform the time unit conversions accordingly. EXAMPLE
struct timeval tv; struct timespec ts; gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec + 0; ts.tv_nsec = 0; RETURN VALUES
If successful, the pthread_cond_timedwait() function will return zero. Otherwise an error number will be returned to indicate the error. ERRORS
The pthread_cond_timedwait() function will fail if: [EINVAL] The value specified by cond, mutex or abstime is invalid. [ETIMEDOUT] The system time has reached or exceeded the time specified in abstime. SEE ALSO
pthread_cond_broadcast(3), pthread_cond_destroy(3), pthread_cond_init(3), pthread_cond_signal(3), pthread_cond_wait(3), gettimeofday(2) STANDARDS
The pthread_cond_timedwait() function conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
May 9, 2010 BSD
All times are GMT -4. The time now is 03:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy