LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2007, 09:08 AM   #1
jmorris8
LQ Newbie
 
Registered: Aug 2005
Posts: 15

Rep: Reputation: 0
Naming files with date added


I'm using Cron to specify a list of jobs that output network scans. I would like the date to be appended to the end of the filenames. Such as reportYYYYMMDD.html.

I was hoping I could include something like this in my cron file...

namedate = 'date +%Y%m%d'

/home/reports/reports$namedate.html

But I'm not sure if this would work, would I need to create a seperate script then call on that script in the cron batch?

Thanks.
 
Old 02-23-2007, 09:22 AM   #2
tuxrules
Senior Member
 
Registered: Jun 2004
Location: Chicago
Distribution: Slackware64 -current
Posts: 1,158

Rep: Reputation: 62
Quote:
Originally Posted by jmorris8
But I'm not sure if this would work, would I need to create a seperate script then call on that script in the cron batch?
Cron will not call a set of commands like the ones you mentioned...it can only call one command or a script (with multiple commands). I believe you will need a script for that.

Tux,
 
Old 02-23-2007, 09:45 AM   #3
jmorris8
LQ Newbie
 
Registered: Aug 2005
Posts: 15

Original Poster
Rep: Reputation: 0
So from what youre saying, the best way for me to do this would be to use cron to create the reports, then call on a script. This script will take the reports that were just created, and rename them using a date variable to my desired filename. I can then use the script to email the newly renamed reports and archieve them if neccessary?

This is becoming more clear, thanks.
 
Old 02-23-2007, 10:08 AM   #4
tuxrules
Senior Member
 
Registered: Jun 2004
Location: Chicago
Distribution: Slackware64 -current
Posts: 1,158

Rep: Reputation: 62
Quote:
Originally Posted by jmorris8
So from what youre saying, the best way for me to do this would be to use cron to create the reports, then call on a script. This script will take the reports that were just created, and rename them using a date variable to my desired filename. I can then use the script to email the newly renamed reports and archieve them if neccessary?

This is becoming more clear, thanks.
Even better option would be to just make a script to create, rename and postprocess (email, archive etc) reports...all in one go. You can also do that in pieces just like you mentioned.
 
Old 02-23-2007, 01:29 PM   #5
jmorris8
LQ Newbie
 
Registered: Aug 2005
Posts: 15

Original Poster
Rep: Reputation: 0
If I set my variable to "scandate", and enter my new filename as /Reports/germany$scandate.html, will it output as "germany20070223.html"? Thanks.

Oh, and could I put slashes in my variables...example, instead of [scandate='date +%Y%m%d'], could I put [scandate=' +%Y%/m%/d']? Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to have grub translate its own naming to naming scheme under Linux zhjim Linux - Software 6 05-28-2006 08:09 AM
script finding files, placing them and naming the TroelsSmit Linux - Newbie 4 11-18-2004 09:50 PM
script finding files, placing them and naming the TroelsSmit Linux - Networking 0 11-18-2004 02:21 PM
mail server the naming naming convention problem kashan Linux - Newbie 0 07-16-2004 02:08 PM
What is the naming convention for files in rcX.d? roshko Linux - Newbie 2 09-01-2003 04:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration