LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-22-2003, 05:35 PM   #1
Pcghost
Senior Member
 
Registered: Feb 2003
Location: The Arctic
Distribution: Fedora, Debian, OpenSuSE and Android
Posts: 1,820

Rep: Reputation: 46
Can anyone spot the error in this cron file?


I have the following crontab -l output

01 12 * * * /home/jeff/logmail.sh
01 18 * * * /home/jeff/logmail.sh

And the logmail.sh file looks like this

#!/bin/bash
#
mail iluvspam@aol.com < /var/log/maillog
cat /dev/null > /var/log/maillog
#end

And it doesn't work. I can run the script manually and it works like a charm, so I know it is not the script. What is wrong with the cron file?
 
Old 07-22-2003, 06:23 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
the only thing that could possibly be wrong with that, is if that file maillog is only allowed to be accessed by root and your running this script as user....otherwise your syntax is fine and it should work no problem
 
Old 07-22-2003, 06:24 PM   #3
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
actually just to note:
why don't you post the error you get when you run the script if any.
 
Old 07-22-2003, 06:46 PM   #4
Pcghost
Senior Member
 
Registered: Feb 2003
Location: The Arctic
Distribution: Fedora, Debian, OpenSuSE and Android
Posts: 1,820

Original Poster
Rep: Reputation: 46
There is no error. When I run the script it works like a champ. When cron runs it nothing happens. Wierd. I am trying to use webmin now to set up the cron job. Maybe I missed something doing it by hand..
 
Old 07-22-2003, 06:54 PM   #5
sewer_monkey
Member
 
Registered: May 2002
Location: Toronto, ON, Canada
Distribution: Ubuntu, Debian, RedHat/CentOS
Posts: 624

Rep: Reputation: 31
Quote:
Originally posted by Pcghost
There is no error. When I run the script it works like a champ. When cron runs it nothing happens. Wierd. I am trying to use webmin now to set up the cron job. Maybe I missed something doing it by hand..
Do you get any e-mail from cron? If there are permissions issues, you should get an e-mail with the error messages. To make sure that you get the e-mail, add the followind line at the beginning of the crontab file:
Code:
MAILTO=username
where username is, obviously, your UNIX username on the system.

Also, by default, on some distributions cron is disabled for regular users, and the cron daemon is not even started. Doublecheck and see if some sort of a cron daemon is running. For example on my system you'd see the following:
Code:
[rouben@einstein rouben]$ ps ax | grep cron
 1514 ?        S      0:01 crond
10166 pts/1    S      0:00 grep cron
[rouben@einstein rouben]$
This tells me that the cron daemon (crond) is up and running and its PID is 1514.

Don't bother with Webmin; your syntax is fine.

P.S. You did use crontab -e to edit your crontab, did you?
 
Old 07-22-2003, 07:13 PM   #6
Pcghost
Senior Member
 
Registered: Feb 2003
Location: The Arctic
Distribution: Fedora, Debian, OpenSuSE and Android
Posts: 1,820

Original Poster
Rep: Reputation: 46
I run this as root. If I manually execute the script (bash logmail.sh) it sends me a message from root with the contents of the log exactly as I wanted it. I ran a "PS -A" and crond is running. I did use crontab -e. When I type crontab -l it lists the cron jobs as shown in my first post.

I will let it run tonight as the next schedualed occurance is at 6pm (it's 4 now) and see if it goes..

Do I need to restart crond each time I make a change?
 
Old 07-23-2003, 03:50 PM   #7
HappyDude
Member
 
Registered: Jul 2003
Posts: 140

Rep: Reputation: 15
I dunno, check the permissions....
 
  


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
F-Spot brokenflea Slackware 10 12-29-2005 05:02 PM
qmail (LWQ) installation error *spot the n00b* dannyboynslu2 Linux - Software 1 07-30-2005 12:00 PM
Cron output to a file Temujin_12 Linux - General 5 02-23-2005 02:52 PM
No More Cron Mail, Cron Error? Xhost Linux - General 3 07-26-2004 05:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:01 AM.

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