LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-05-2008, 07:59 AM   #1
montblanc
LQ Newbie
 
Registered: Feb 2008
Posts: 7

Rep: Reputation: 0
Crontab does not create log file


Hi

Our customer is using Red Hat Enterprise 4.4 kernel 2.6.9-42

We are using the root user and we are at the KVM console (not remotely)

With crontab -e i see:

10 11 * * * /bin/echo "text ...." >1 /tmp/cron_log 2 >&1

the cron_log is not created even if we simply put /bin/echo "text..." > /tmp/cron_log. Nothing is created.

But if we execute the command direclty from the command line, /bin/echo "text...." > /tmp/cron_log, this log file is correclty created.


anacron deamon is running
crond deamon is running

Why is the log file not created, when using the crontab file?
is this a bug?



please help
 
Old 02-05-2008, 08:12 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858
Currently you're logging to a file called "1", proper syntax to append line to text file should be '10 11 * * * /bin/echo "text ...." >>/tmp/cron_log 2>&1'.
 
Old 02-05-2008, 08:22 AM   #3
montblanc
LQ Newbie
 
Registered: Feb 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Crontab does not create log file

unSpawn

Ok, you are right. i put a syntax error in the text in the question below , but still, the log file , even with correct syntax, is not created. As i already mentioned, with crontab -e we change the line to 15 11 * * * /bin/echo "example text" > /tmp/cron_log, save file. then we wait.. a few minutes and we run the ls command in /tmp folder but log does not show up log file is not created.

But if we execute the command direclty from the command line, /bin/echo "text...." > /tmp/cron_log, this log file is correclty created.

No errors in Systemlog viewer (GUI) , simply nothing happens. no log created with crontab

something goes wrong with crontab config or what ?

please help
 
Old 02-05-2008, 08:36 AM   #4
wildcat22
Member
 
Registered: Nov 2003
Location: USA
Distribution: Ubuntu
Posts: 102

Rep: Reputation: 15
For sanity purposes, try putting the commands you want to run in a shell script (don't forget to make it executable). Then try to run your shell script in cron, be sure to still include the full path to the script, as you had previously.

For example:
crontab:
* * * * * /usr/bin/myscript.sh

myscript.sh:
#!/bin/bash
echo Date: `date` >> /tmp/mylog.txt
 
Old 02-05-2008, 08:59 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,310
Blog Entries: 54

Rep: Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858Reputation: 2858
Also two other things: 0) do you by any chance have the user listed in /etc/cron.deny or 1) is there cron daemon e-mail with errors in $USER's mailbox?
 
  


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
How to create log file from script fotoguy Programming 12 03-27-2012 06:39 AM
Create log file against a script shipon_97 Linux - Newbie 1 01-02-2008 11:54 AM
How to create a log File using tee?? rmvinodh123 Programming 1 04-12-2007 02:21 AM
need to create log file sanjay2004 Linux - Newbie 6 02-27-2006 11:11 AM
Script to create a log file satimis Programming 15 01-16-2006 06:39 AM


All times are GMT -5. The time now is 07:39 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration