The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Capturing and sending of vmstat output everyday yuvanash Shell Programming and Scripting 1 02-25-2009 03:48 AM
Everyday appending info about all processes which are active.. mavikartal Shell Programming and Scripting 1 12-25-2008 11:32 PM
Google For Everyday Life - Part 1 iBot Cartoons for Geeks 0 08-13-2008 07:30 AM
Cronjob - Redirect mail output to file, LINES & COLUMNS jharvey Shell Programming and Scripting 0 04-14-2008 04:19 PM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 08:30 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-25-2009
umarsa umarsa is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
How to make cronjob output to different files everyday

Hello,

I have a cronjob that i am currently running which is as follows:
php /home/****/cronjob.php --debug 2>&1 >> /home/cronjoboutput.txt

That, as you may know, logs the output to a file called cronjoboutput.txt in the home directory.

I want that cronjob to output to a different file everyday so if today is the 25th (25-10-2009) then it will output to "/home/ilog/25-10-2009.log". And if the date changes to the 26th then it starts logging to "/home/ilog/26-10-2009.log".

Can someone please write up a command that does this for me?

Thanks!
  #2 (permalink)  
Old 10-25-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,972
Hello!

Per forum rules, and the benefit of all users, please search the forums before posting a question.

You can easily search the forums using our internal Google search engine or our advanced internal search engine. You can also search our huge UNIX and Linux database by user generated tags or search the database for unanswered questions and provide an answer.

Thank you.

The UNIX and Linux Forums

---------- Post updated at 22:38 ---------- Previous update was at 22:37 ----------

Searching for "date in filename" gives (at least) this, this, this, and that.
  #3 (permalink)  
Old 10-25-2009
jgt jgt is online now
Registered User
  
 

Join Date: Apr 2007
Location: 44.21.48N 80.50.15W
Posts: 457
set the output file to


Code:
>/home/ilog/`date +"%m-%d-%Y"`.txt

  #4 (permalink)  
Old 10-25-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 761

Code:
>> /home/ilog/$(/bin/date +%d-%m-%Y).log

  #5 (permalink)  
Old 10-25-2009
umarsa umarsa is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
Hey im sorry but i did search but i didnt find anything that i thought would be helpful.. I am very new to this.

---------- Post updated at 06:40 PM ---------- Previous update was at 05:56 PM ----------

Hello.

From the /var/log/cron i see that it says this now:
Oct 25 23:35:01 server crond[13367]: (root) CMD (php /home/admin/clients.hostwoot.com/cron/cronjob.php --debug 2>&1 >> /ipanel_log/$(/bin/date +)

It looks like the command i put there is not working because i dont see any files there...

The cron:
php /home/***/cronjob.php --debug 2>&1 >> /ipanel_log/$(/bin/date +%d-%m-%Y).log
  #6 (permalink)  
Old 10-26-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
You need to escape percentage signs \% in crontab lines because they have a meaning to cron (see the manual for your crontab).
Whether either of the suggested solutions will then work depends on what shell your operating system uses for cron jobs. In general it is better to write a controlling script containing a shebang and any local environment settings and then call that script from cron.


Also, there are 6 parameters to a crontab line. Your example line does not look like a normal crontab line.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0