Sponsored Content
Top Forums UNIX for Dummies Questions & Answers getting the date in crontab command Post 302150738 by awk on Wednesday 12th of December 2007 11:50:52 AM
Old 12-12-2007
Quote:
Originally Posted by pranavagarwal
Hi All,
There is a requirement to create a file everyday using the cronjob with the date as its name.

any suggestions for the crontab command that'll serve this purpose?

e.g.
Code:
02 30 * * * touch abcd.`date +%d.%m.%y`

needless to say.. this doesn't work..

looking fwd to lots of sugestions..Smilie
Not sure how useful this will be - AIX handles it just fine -

55 09 * * * touch `date +abcd.\%m.\%d.\%Y.dat`

Same thing in SUN doesn't. But an interesting problem.

If you leave off the backslashes, SUN treats the rest of the line following the % as a comment and ignores.

The only way I can think of to try and get around, is to put the command in a script, that you execute as a cron job.
 

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
TOUCH(1)							   User Commands							  TOUCH(1)

NAME
touch - change file timestamps SYNOPSIS
touch [OPTION]... FILE... DESCRIPTION
Update the access and modification times of each FILE to the current time. Mandatory arguments to long options are mandatory for short options too. -a change only the access time -B, --backward=SECONDS Modify the time by going back SECONDS seconds. For example, touch -r foo -B 5 bar will make the file bar 5 seconds older than file foo. -c, --no-create do not create any files -d, --date=STRING parse STRING and use it instead of current time -F, --forward=SECONDS Modify the time by going forward SECONDS seconds. For example, touch -r foo -F 5 bar will make the file bar 5 seconds newer than file foo. -f (ignored) -m change only the modification time -r, --reference=FILE use this file's times instead of current time -t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time --time=WORD set time given by WORD: access atime use (same as -a) modify mtime (same as -m) --help display this help and exit --version output version information and exit Note that the -d and -t options accept different time-date formats. AUTHOR
Written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for touch is maintained as a Texinfo manual. If the info and touch programs are properly installed at your site, the command info touch should give you access to the complete manual. touch (coreutils) 4.5.3 October 2002 TOUCH(1)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy