Solved [Solved] Crontab can't see file, ls -l shows it's there

Hey all, I created a quick little file to run every five minutes and running it from the command line it works fine. I put it in crontab and now I'm getting this error sent to me:

Code:
(Cron <root@FreeNag> root /usr/home/jobee/runmrtg)
root: not found

Again, I can run this from the command line and it works fine but crontab can't see it. The path is correct. Any ideas?

Thanks,

Joe B
 
Re: Crontab can't see file, ls -l shows it's there

cron(8) is trying to execute the "root" command, so maybe your crontab line is wrong. The system's crontab (/etc/crontab) has 7 fields:

Code:
minute hour mday month wday who command

The user's crontab (modified with crontab -e) does not have the "who" field because every command executed via the user's crontab runs with the user's credentials.

See crontab(5) for more information.
 
Re: Crontab can't see file, ls -l shows it's there

Hi @Dies_Irae, I moved my file to /usr/home/jobee/runmrtg and put it in my crontab that way:

Code:
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
# minute hour mday month wday who command
#
# Crontab -e doesn't use "who"
#
*/5 * * * * /usr/home/jobee/runmrtg
0 0 * * * /usr/home/jobee/bin/NagBack

But now I'm getting two of these email alerts every five minutes:

Code:
2014-01-09 15:20:03: ERROR: It looks as if you are running two copies of mrtg in parallel on
       the same config file. There is a lockfile (/usr/home/jobee/Config/mrtg_192.168.1.20.cfg_l) and it is
       is only 1 seconds old ... Check your crontab.
       (/etc/crontab and /var/spool/cron/root)

I ran crontab -r and then created a new crontab but I'm still getting this error. Crontab -l just gives me the one crontab.

I don't know if it makes a difference but the two emails have similar but different subject lines:

Code:
Cron <root@FreeNag> /usr/home/jobee/runmrtg
and 
Cron <root@FreeNag> 	/usr/home/jobee/runmrtg

Notice the gap between the FreeNag> and the /usr. Any ideas on any other possible crontabs that might be running?

Thanks,

Joe B
 
Last edited by a moderator:
Re: Crontab can't see file, ls -l shows it's there

How long does it take your runmrtg script to execute? Is it possible the second iteration of the script is starting before the first iteration completes? runmrtg is set to run every 5 minutes per the entry in /var/cron/tabs/root.
 
Re: Crontab can't see file, ls -l shows it's there

The logs says that the lockfile is "only 1 seconds old", this means that mrtg has been executed 2 times in 1 second, and you receive 2 mail from cron every 5 minutes, so I'm pretty sure you have 2 cron jobs starting at the same time.

How did you configure the cron job the first time? By modifying /etc/crontab or by running crontab -e?
 
Re: Crontab can't see file, ls -l shows it's there

Thank you @Dies_Irae, that was it! I checked /etc/crontab and found the second entry. Now I only have one entry running and we're golden.

Thanks again,

Joe B
 
Last edited by a moderator:
Re: Crontab can't see file, ls -l shows it's there

I don't see an option to mark a thread as being solved. Am I not looking in the right places or is there no such option?
 
Edit the first post in the thread, and manually add "[Solved]" to the title.

There's no easy/simple method for marking a thread solved in this version of the forums software.
 
Back
Top