LinuxQuestions.org
Help answer threads with 0 replies.
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-06-2013, 09:27 AM   #1
Boomn4x4
LQ Newbie
 
Registered: Feb 2009
Posts: 8

Rep: Reputation: 0
Cron not creating new log file


I have a cron job that executes a perl script. I have the cron job directed to output stdout to log file. As long as the file already exists, it works fine. However, if the log file doesn't exist, the file is not created and nothing gets logged.

my cron entry looks like:
0 */4 * * * (. /home/user/envfile ; /home/user/myscript.pl 2>&1 | tee -a /home/user/log/mylogfile.log)

Thank you
 
Old 02-06-2013, 09:35 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

Why the tee command? From cron there is no screen it can output to.

Best option: handle the output from within the perl script.

Or change the cron line to:
Code:
0 */4 * * * (. /home/user/envfile ; /home/user/myscript.pl > /home/user/log/mylogfile.log 2>&1)
 
Old 02-06-2013, 10:10 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I agree the tee command is useless in a cron job, but the file should be created unless the directory /home/user/log doesn't exist. Any message from the cron daemon in the crontab owner's mailbox?
 
Old 02-06-2013, 10:14 AM   #4
Boomn4x4
LQ Newbie
 
Registered: Feb 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
I agree the tee command is useless in a cron job, but the file should be created unless the directory /home/user/log doesn't exist. Any message from the cron daemon in the crontab owner's mailbox?
Yes... Its a permissions issue. The directory the log file was in didn't have write permission for that user... though the log file itself did. If the file wasn't there, the user couldn't write the file to create it, but once it was created, it could write to it.

Thanks for pointing me to the mail.
 
Old 02-06-2013, 10:15 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You're welcome!
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Creating a Log file to log activity time in Ubuntu mint nervous137 Linux - Newbie 4 04-19-2012 07:37 AM
[SOLVED] how to create cron log file cnt Linux - Server 2 09-05-2011 04:51 AM
Creating a Cron File Spyder512 Linux - Newbie 4 08-17-2011 11:08 AM
var cron log file Markus_87 Linux - Newbie 3 10-28-2009 08:27 PM
Cron - not creating log file t3___ Linux - Newbie 3 02-26-2004 06:50 PM


All times are GMT -5. The time now is 04:29 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration