Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to use datecalc for adding hours Post 302201591 by ucbus on Monday 2nd of June 2008 02:29:03 PM
Old 06-02-2008
Thanks
Quote:
Originally Posted by Perderabo
Code:
#! /usr/bin/ksh
date[0]=2008
date[1]=5
date[2]=28
hour=0
while : ; do
        printf "%02d%02d%4d%02d00\n" ${date[1]} ${date[2]} ${date[0]} $hour
        if (( hour == 23)) ; then
                ((hour=0))
                set -A date $(datecalc -a ${date[*]} + 1)
        else
                ((hour=hour+1))
        fi
done

correct me if I am wrong.
I have datecalc.ksh and the above script say "test.ksh" in the same directory and when I run test.ksh I am getting "datecalc not found" error.

Should n't this line be:
Code:
set -A date $(datecalc -a ${date[*]} + 1)

modified line
Code:
set -A date $(. datecalc.ksh -a ${date[*]} + 1)

Please see the folating point and .ksh extensiton. Please let me know if I am missing anything.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a help Please- runing the perderabos script datecalc

i have a script in bourne called cdrsnokia.sh and inside of it calls a script called resta_dias where it calls the datecalc script (perderabos date calculator). The purpose is to rest (-) one day arithmetical operation the content of each line and the result is passed to another file lista2;after... (1 Reply)
Discussion started by: alexcol
1 Replies

2. Shell Programming and Scripting

datecalc

Is there no simple way using 'date' command just to get number of days from given date. ie. if I pass 2007-01-15 as an argument. I want to obtain result as 015 Simarly for 2007-02-10. I want to obtain result as 41. Can't this be achieved by simple 1 or 2 lines of command (date). As this is... (1 Reply)
Discussion started by: tostay2003
1 Replies

3. Shell Programming and Scripting

datecalc question.

I have a script that works perfectly on a linux box, but I am going to have to move it over to solaris which I have never really worked with. I was a bit miffed that date -d was not available on solaris so I started looking for alternative soltuoins and found this forum and datecalc. But I... (4 Replies)
Discussion started by: trey85stang
4 Replies

4. UNIX for Dummies Questions & Answers

Doubt in datecalc.....

I have a doubt in date conversion. Can anyone explain the logic behind the date2jd and jd2date in datecalc function specified in this forum. I could not understand what the number are actually representing. Please explain...bcoz i am doing a program with this one.. Note: No need to... (1 Reply)
Discussion started by: sivakumar.rj
1 Replies

5. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

6. Shell Programming and Scripting

How to subtract time by 10 minutes in datecalc tool

Hi guys. I am trying to subtract 10 minutes from the current Unix system date and time. I have the datecalc provided here but it is mainly the date and not the time. Please check on how can i subtract 10 minutes from the current time using datecalc or any other shell scripting that will... (2 Replies)
Discussion started by: bantiloe
2 Replies

7. Shell Programming and Scripting

Adding hours to current date

Hi, any idea how to add hours to current date in unix. thanks in advance (9 Replies)
Discussion started by: Abhijeet_Atti
9 Replies

8. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

9. Shell Programming and Scripting

Adding 48 hours to DateTime

Hey Guys, I have looked for a solution throughout the forum for my particular question, but I cant find one. So I'm sorry if I overlooked it. I need to be able to 48 add hours to a particular DateTime string. I have a variable named $startTime I would like to be able to take that... (1 Reply)
Discussion started by: chagan02
1 Replies

10. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
BACKUP_SETEXP(8)					       AFS Command Reference						  BACKUP_SETEXP(8)

NAME
       backup_setexp - Sets the expiration date for existing dump levels.

SYNOPSIS
       backup setexp -dump <dump level name>+
	   [-expires <expiration date>+] [-localauth]
	   [-cell <cell name>] [-help]

       backup se -d <dump level name>+
	   [-e <expiration date>+]
	   [-l] [-c <cell name>] [-h]

DESCRIPTION
       The backup setexp command sets or changes the expiration date associated with each specified dump level, which must already exist in the
       dump hierarchy.

       Use the -expires argument to associate an expiration date with each dump level. When the Backup System subsequently creates a dump at the
       dump level, it uses the specified value to derive the dump's expiration date, which it records on the label of the tape (or backup data
       file). The Backup System refuses to overwrite a tape until after the latest expiration date of any dump that the tape contains, unless the
       backup labeltape command is used to relabel the tape. If a dump level does not have an expiration date, the Backup System treats dumps
       created at the level as expired as soon as it creates them.

       (Note that the Backup System does not automatically remove a dump's record from the Backup Database when the dump reaches its expiration
       date, but only if the tape that contains the dump is recycled or relabeled. To remove expired and other obsolete dump records, use the
       backup deletedump command.)

       Define either an absolute or relative expiration date:

       o   An absolute expiration date defines the month/day/year (and, optionally, hour and minutes) at which a dump expires. If the expiration
	   date predates the dump creation time, the Backup System immediately treats the dump as expired.

       o   A relative date defines the number of years, months, or days (or a combination of the three) after the dump's creation that it expires.
	   When the Backup System creates a dump at the dump level, it calculates an actual expiration date by adding the relative date to the
	   start time of the dump operation.

       If the command is used to change an existing expiration date associated with a dump level, the new date applies only to dumps created after
       the change. Existing dumps retain the expiration date assigned at the time they were created.

OPTIONS
       -dump <dump level name>+
	   Specifies the full pathname of each dump level to assign the expiration date specified by the -expires argument.

       -expires <expiration date>+
	   Defines the absolute or relative expiration date to associate with each dump level named by the -dump argument. Absolute expiration
	   dates have the following format:

	      [at] {NEVER | <mm>/<dd>/<yyyy> [<hh>:<MM>] }

	   where the optional word at is followed either by the string "NEVER", which indicates that dumps created at the dump level never expire,
	   or by a date value with a required portion (<mm> for month, <dd> for day, and <yyyy> for year) and an optional portion (<hh> for hours
	   and <MM> for minutes).

	   Omit the <hh>:<MM> portion to use the default of midnight (00:00 hours), or provide a value in 24-hour format (for example, "20:30" is
	   8:30 p.m.).	Valid values for the year range from 1970 to 2037; higher values are not valid because the latest possible date in the
	   standard UNIX representation is in February 2038. The command interpreter automatically reduces later dates to the maximum value.

	   Relative expiration dates have the following format:

	      [in] [<years>y] [<months>m] [<days>d]

	   where the optional word in is followed by at least one of a number of years (maximum 9999) followed by the letter "y", a number of
	   months (maximum 12) followed by the letter "m", or a number of days (maximum 31) followed by the letter "d". If providing more than one
	   of the three, list them in the indicated order. If the date that results from adding the relative expiration value to a dump's creation
	   time is later than the latest possible date in the UNIX time representation, the Backup System automatically reduces it to that date.

       -localauth
	   Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. The backup command interpreter presents it to
	   the Backup Server, Volume Server and VL Server during mutual authentication. Do not combine this flag with the -cell argument. For more
	   details, see backup(8).

       -cell <cell name>
	   Names the cell in which to run the command. Do not combine this argument with the -localauth flag. For more details, see backup(8).

       -help
	   Prints the online help for this command. All other valid options are ignored.

EXAMPLES
       The following example associates an absolute expiration date of 10:00 p.m. on 31 December 1999 with the dump level "/1998/december":

	  % backup setexp -dump /1998/december -expires at 12/31/1999 22:00

       The following example associates a relative expiration date of 7 days with the two dump levels "/monthly/week1" and "/monthly/week2":

	  % backup setexp -dump /monthly/week1 /monthly/week -expires 7d

PRIVILEGE REQUIRED
       The issuer must be listed in the /etc/openafs/server/UserList file on every machine where the Backup Server is running, or must be logged
       onto a server machine as the local superuser "root" if the -localauth flag is included.

SEE ALSO
       backup(8), backup_adddump(8), backup_deldump(8), backup_listdumps(8)

COPYRIGHT
       IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.

       This documentation is covered by the IBM Public License Version 1.0.  It was converted from HTML to POD by software written by Chas
       Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.

OpenAFS 							    2012-03-26							  BACKUP_SETEXP(8)
All times are GMT -4. The time now is 04:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy