?
Solved

Format Cron output

Posted on 2006-06-05
6
Medium Priority
?
869 Views
Last Modified: 2013-12-27

59 23 * * * /path/to/script.sh>>`/usr/bin/date '+\%Y-\%m-\%d'`.log
creates a file with the name "\2006-\05-\17.log"

how can I make it create a file with the name 2006-05-17.log?

59 23 * * * /path/to/script.sh>>`/usr/bin/date '+%Y-%m-%d'`.log  <--- this does not create a file at all
0
Comment
Question by:jculkincys
  • 2
  • 2
  • 2
6 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 16837612
The problem is your quotes around the date format.

just remove the quotes, ie:


59 23 * * * /path/to/script.sh>>`/usr/bin/date +\%Y-\%m-\%d`.log
0
 
LVL 12

Expert Comment

by:geotiger
ID: 16842558
You need to use double quote instead of single quote:

59 23 * * * /path/to/script.sh>>`/usr/bin/date +"\%Y-\%m-\%d"`.log


0
 
LVL 2

Author Comment

by:jculkincys
ID: 16842921
Awesome that worked thanks

any tips on how I can make this job from a different directory (other than my $HOME)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:geotiger
ID: 16842945

You mean saving the log to different location? Here it is


59 23 * * * /path/to/script.sh>> /other/dir/`/usr/bin/date +"\%Y-\%m-\%d"`.log
0
 
LVL 2

Author Comment

by:jculkincys
ID: 16842963
no when the script runs it creates txt files in the directory that is it being run from

i think think by default cron runs all job from the HOME directory

I was wondering if there was a way to change this setting for this particular job
0
 
LVL 48

Expert Comment

by:Tintin
ID: 16848226
geotiger.

Double quotes don't work (at least on Solaris 9/10).

jculkincys.

With standard Solaris cron, you can't change the cron envrionment for a user, but I don't really see why you'd want to do that anyway, given that you can direct the log file to any directory you like.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question