LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can anyone spot the error in this cron file? (https://www.linuxquestions.org/questions/linux-software-2/can-anyone-spot-the-error-in-this-cron-file-74977/)

Pcghost 07-22-2003 04:35 PM

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? :scratch:

DrOzz 07-22-2003 05:23 PM

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

DrOzz 07-22-2003 05:24 PM

actually just to note:
why don't you post the error you get when you run the script if any.

Pcghost 07-22-2003 05:46 PM

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..

sewer_monkey 07-22-2003 05:54 PM

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?

Pcghost 07-22-2003 06:13 PM

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?

HappyDude 07-23-2003 02:50 PM

I dunno, check the permissions....


All times are GMT -5. The time now is 04:40 AM.