Sponsored Content
Top Forums UNIX for Dummies Questions & Answers getting the date in crontab command Post 302150329 by prowla on Tuesday 11th of December 2007 03:15:01 AM
Old 12-11-2007
Why not try preceding the commands with their path (eg. /usr/bin/touch abcd.`/usr/bin/date +%d.%m.%y`)?

I would also suggest putting your timestamp year.month.date, as your files will show up in order in ls listings then.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

why the date format dont work in crontab

Hi I tried to put a cron job which pipes the logfile appended to date +%d but it didnt work . anyone know how to make this happen thanks in advance -prasad (7 Replies)
Discussion started by: p4cldba
7 Replies

2. Shell Programming and Scripting

How to check crontab edited date and time?

How to check when was the last time the crontab was updated and also what was the modification done ? (2 Replies)
Discussion started by: mail2sant
2 Replies

3. Shell Programming and Scripting

date command issue from crontab

Hello Experts, I am facing problem in date command with TZ test.sh Output : 26-May-2010 27-May-2010 I scheduled this script everyday at 1 a.m 00 01 * * * sh test.sh when i was called this script test.sh from crontab , it was giving me other output (1 Reply)
Discussion started by: pritish.sas
1 Replies

4. Shell Programming and Scripting

date command issue from crontab

Hi Expert, I am using TZ for extracting yesterday date and day before yesterday date example : date_yes=`TZ="GMT+28" date +'%d-%b-%Y'` date_dbyes=`TZ="GMT+48" date +'%d-%b-%Y'` echo $date_yes $date_dbyes 26-May-2010 27-May-2010 I have written a small script for the same named... (1 Reply)
Discussion started by: pritish.sas
1 Replies

5. Solaris

Crontab date setting problem

Hi, 0 9 1,2,3,4,5,6,7 3,4 6 I want a cronjob to run on every 1st Sat of Mar & Apr. But the above schedule is running is running on the 1st 7 days. How do i rectify it? Thanks in advance. (2 Replies)
Discussion started by: beginningDBA
2 Replies

6. Solaris

Crontab date setting problem

Hi, i wanted to schedule a backup script to run on 7.30pm every 1st Sat of month MAR, APR, SEP, OCT. Am i understanding it correctly? Because it doesn't seem to run according to the schedule i needed. = (7.30pm) & (1st to 7th day of the month) & (MAR, APR, SEP, OCT) & (Sat) 30 19 1-7... (1 Reply)
Discussion started by: beginningDBA
1 Replies

7. Solaris

Solaris 9 Zone : Date command in crontab shows delayed(One Hour) output

SOLARIS 9 Zone : date command in crontab shows delayed(One Hour) output Hi folks, the date command shows the correct date and time, How ever, if the date command executed through crontab in any form of scrip the output shows as one hour delayed, similar to date -u.. Can some one help in... (12 Replies)
Discussion started by: judi
12 Replies

8. Shell Programming and Scripting

Date on crontab

Hi, I'm new to Linux and I'm trying to do some script. In particular, a part of that script is the following one: #!/usr/local/bin/bash path_s="/home/piros2/" input_list=$path_s"input_list.txt" date +%Y-%m-%d --date=" 10 days ago" >> $input_list The script (script.sh) is executed from... (2 Replies)
Discussion started by: Piros
2 Replies

9. Shell Programming and Scripting

Pass system date and sysdate-7 in script through crontab

Hi , I have to schedule one job in crontab, but with two parameters. 1. Sysdate in YYYYMMDD format 2. Sysdate - 7 in YYYYMMDD format Please suggest how to do that. Thanks in advance. (1 Reply)
Discussion started by: Anupam_Halder
1 Replies

10. UNIX for Beginners Questions & Answers

Date in filename from crontab

Hi, on AIX The following echo "rr" > myfile_$(date +"%m_%d_%Y").log gives: myfile_10_23_2019.log But in crontab: 00 03 * * 1-6 /u01/script.sh >/tmp/myfile_$(date +"%m_%d_%Y").log 2>&1 gives: myfile_Wed Oct 23 03:00:00 CEST 2019 How can one have: myfile_10_23_2019.log (6 Replies)
Discussion started by: big123456
6 Replies
date(1) 							   User Commands							   date(1)

NAME
date - write the date and time SYNOPSIS
/usr/bin/date [-u] [ +format] /usr/bin/date [ -a [-]sss.fff] /usr/bin/date [-u] [ [mmdd] HHMM | mmddHHMM [cc] yy] [.SS] /usr/xpg4/bin/date [-u] [ +format] /usr/xpg4/bin/date [ -a [-]sss.fff] /usr/xpg4/bin/date [-u] [ [mmdd] HHMM | mmddHHMM [cc] yy] [.SS] DESCRIPTION
The date utility writes the date and time to standard output or attempts to set the system date and time. By default, the current date and time is written. Specifications of native language translations of month and weekday names are supported. The month and weekday names used for a language are based on the locale specified by the environment variable LC_TIME. See environ(5). The following is the default form for the "C" locale: %a %b %e %T %Z %Y For example, Fri Dec 23 10:10:42 EST 1988 OPTIONS
The following options are supported: -a [-]sss.fff Slowly adjust the time by sss.fff seconds (fff represents fractions of a second). This adjustment can be positive or nega- tive. The system's clock is sped up or slowed down until it has drifted by the number of seconds specified. Only the super- user may adjust the time. -u Display (or set) the date in Greenwich Mean Time (GMT--universal time), bypassing the normal conversion to (or from) local time. OPERANDS
The following operands are supported: +format If the argument begins with +, the output of date is the result of passing format and the current time to strftime(). date uses the conversion specifications listed on the strftime(3C) manual page, with the conversion specification for %C deter- mined by whether /usr/bin/date or /usr/xpg4/bin/date is used: /usr/bin/date Locale's date and time representation. This is the default output for date. /usr/xpg4/bin/date Century (a year divided by 100 and truncated to an integer) as a decimal number [00-99]. The string is always terminated with a NEWLINE. An argument containing blanks must be quoted; see the EXAMPLES section. mm Month number dd Day number in the month HH Hour number (24 hour system) MM Minute number SS Second number cc Century (a year divided by 100 and truncated to an integer) as a decimal number [00-99]. For example, cc is 19 for the year 1988 and 20 for the year 2007. yy Last two digits of the year number. If century (cc) is not specified, then values in the range 69-99 shall refer to years 1969 to 1999 inclusive, and values in the range 00-68 shall refer to years 2000 to 2068, inclusive. The month, day, year number, and century may be omitted; the current values are applied as defaults. For example, the following entry: example% date 10080045 sets the date to Oct 8, 12:45 a.m. The current year is the default because no year is supplied. The system operates in GMT. date takes care of the conversion to and from local standard and daylight time. Only the super-user may change the date. After successfully setting the date and time, date displays the new date according to the default format. The date command uses TZ to determine the correct time zone information; see environ(5). EXAMPLES
Example 1: Generating Output The following command: example% date '+DATE: %m/%d/%y%nTIME:%H:%M:%S' generates as output DATE: 08/01/76 TIME: 14:45:05 Example 2: Setting the Current Time The following command sets the current time to 12:34:56: example# date 1234.56 Example 3: Setting Another Time and Date in Greenwich Mean Time The following command sets the date to January 1st, 12:30 am, 2000: example# date -u 010100302000 This is displayed as: Thu Jan 01 00:30:00 GMT 2000 ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of date: LANG, LC_ALL, LC_CTYPE, LC_TIME, LC_MESSAGES, and NLSPATH. TZ Determine the timezone in which the time and date are written, unless the -u option is specified. If the TZ variable is not set and the -u is not specified, the system default timezone is used. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/date +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ /usr/xpg4/bin/date +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
strftime(3C), attributes(5), environ(5), standards(5) DIAGNOSTICS
no permission You are not the super-user and you tried to change the date. bad conversion The date set is syntactically incorrect. NOTES
If you attempt to set the current date to one of the dates that the standard and alternate time zones change (for example, the date that daylight time is starting or ending), and you attempt to set the time to a time in the interval between the end of standard time and the beginning of the alternate time (or the end of the alternate time and the beginning of standard time), the results are unpredictable. Using the date command from within windowing environments to change the date can lead to unpredictable results and is unsafe. It can also be unsafe in the multi-user mode, that is, outside of a windowing system, if the date is changed rapidly back and forth. The recommended method of changing the date is 'date -a'. Setting the system time or allowing the system time to progress beyond 03:14:07 UTC Jan 19, 2038 is not supported on Solaris. SunOS 5.10 11 May 2004 date(1)
All times are GMT -4. The time now is 08:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy