LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-21-2004, 01:33 PM   #1
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Rep: Reputation: 0
cron job <defunct> error?


Fairly new to using cron to automate tasks and have come across an error <defunct> as job is run... Some details:

Cron job line

*/2 * * * 1-5 sh /path/to/script.sh >> /tmp/dhcp_log 2>&1

Contents of script.sh

today="date +%m.%d.%Y"
if HOME=/path/to
then
if test -f /path/to/restart
then
if test -f /path/to/dhcpd.conf
then
$today
echo "----------------------------------------------------------------"
echo "File was found. Attempting to restart the DHCP Service."
echo "Please wait..."
if killall -HUP dhcpd
then
echo "DHCP Service has been stopped."
/usr/sbin/dhcpd -cf /path/to/dhcpd.conf
echo "DHCP Service was started successfully."
echo "/path/to/dhcpd.conf"
rm /path/to/restart
if test -f /path/to/restart
then
rm -dfr /path/to/restart
echo "Removed temporary file used to flag mandatory restart"
else
echo "No file found to flag mandatory restart"
fi
else
echo "DHCP Service was started"
/usr/sbin/dhcpd -cf /path/to/dhcpd.conf
rm /path/to/restart
echo "----------------------------------------------------------------"
fi
else
echo "File was not found"
fi
else
exit 0
fi
else
exit 0
fi

If I run the script alone it works fine... however if I run it through cron this is the error I recieve using ps xaf

root 711 0.0 0.0 1484 324 ? S 2003 0:00 /usr/sbin/crond -l10
root 19825 0.0 0.0 1480 608 ? S 10:41 0:00 /usr/sbin/crond -L /tmp/crond
root 20127 0.0 0.0 0 0 ? Z 11:14 0:00 [crond] <defunct>
root 20128 0.0 0.0 0 0 ? Z 11:14 0:00 [crond] <defunct>

Now the contents of the error log I am running crond with...

unable to exec /usr/sbin/sendmail -t, user -oem, output to sink nullUSER root pid 20207 cmd sh /us\
r/local/www/dhcp/bin/dhcp.sh >> /tmp/dhcp_log 2>&1^M
unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null

Permissions on shell script are here...

-rwxr-xr-t 1 root root 1340 Jan 21 11:13 dhcp.sh

If anyone knows why this is occuring please let me know... as you can see I am in no way trying to output the results of by script to an email... I need it logged to a file so I may view it later.

Thanks in advance.
 
Old 01-21-2004, 01:45 PM   #2
jhorvath
Member
 
Registered: Sep 2002
Location: OH, USA
Distribution: 2.6.16-1.2096_FC5 #1
Posts: 245

Rep: Reputation: 30
according to the crond manpage , crond attempts to mail the results of the jobs using sendmail. so probably you need sendmail installed, unless you can turn that option off (try a google, there's no such option listed in manpage..)

--jeremy
 
Old 01-21-2004, 01:49 PM   #3
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
Re: <defunct>

Actually everything I have found says to use
command >> /tmp/filename 2>&1
which outputs to a file instead of an email message. I have a couple of cron jobs running this exact method and they all work, as a matter of fact if I run this command from a shell prompt it works...

sh /path/to/shell.sh >> /tmp/error 2>&1

weird huh? if cron runs it i get this error

unable to exec /usr/sbin/sendmail -t, user -oem, output to sink nullUSER root pid 20207 cmd sh /usr/local/www/dhcp/bin/dhcp.sh >> /tmp/dhcp_log 2>&1^M
unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null
 
Old 01-21-2004, 01:56 PM   #4
jhorvath
Member
 
Registered: Sep 2002
Location: OH, USA
Distribution: 2.6.16-1.2096_FC5 #1
Posts: 245

Rep: Reputation: 30
hmm...now i'm reading that if you redirect the output (which you have), it shouldn't be mailed.. (i'm not really big on cron jobs )

this line ::

*/2 * * * 1-5 sh /path/to/script.sh >> /tmp/dhcp_log 2>&1

should it not be 'without' the boldened text? i believe just the /path/to/script.sh is needed because it calls a shell to execute it on its own?

Last edited by jhorvath; 01-21-2004 at 01:59 PM.
 
Old 01-21-2004, 03:22 PM   #5
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
Let me give that idea a try... I will be back in a minute
 
Old 01-21-2004, 03:24 PM   #6
jhorvath
Member
 
Registered: Sep 2002
Location: OH, USA
Distribution: 2.6.16-1.2096_FC5 #1
Posts: 245

Rep: Reputation: 30
dont worry about it...has nothing to do with it..been trying everything to make this thing fail ,...and cannot seem to manage it

these lines ...
root 711 0.0 0.0 1484 324 ? S 2003 0:00 /usr/sbin/crond -l10
root 19825 0.0 0.0 1480 608 ? S 10:41 0:00 /usr/sbin/crond -L /tmp/crond

...this has nothing to do with this problem , but you may not want two cron daemons running during go time..

try making some simple script that just echos HELLOOO or somethin...and run it 'exactly' the same way your trying to run the dhcp script..same permissions and file name (back the other one up),...just like it was the dhcp.sh file and see if you get the same results...

i even set up a cron job to run a simple script without redirecting output...it still didn't cry about sendmail...<?>

Last edited by jhorvath; 01-21-2004 at 03:35 PM.
 
Old 01-21-2004, 03:36 PM   #7
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
Well I killed the cron daemon and restarted it then I modified the cron syntax to read as follows...

*/1 * * * * /path/to/script.sh &> /tmp/errors

Seems to be working fine now...
 
Old 01-21-2004, 03:39 PM   #8
jhorvath
Member
 
Registered: Sep 2002
Location: OH, USA
Distribution: 2.6.16-1.2096_FC5 #1
Posts: 245

Rep: Reputation: 30
WIERD !!

mine was set as

*/1 * * * * sh /path/shit.sh >> /tmp/shit.txt 2>&1

and was working fine?? doesn't make sense to me, but, whatever works i guess
 
  


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
cron error: no job control schentor Linux - Software 2 07-18-2005 12:39 PM
cron job wbatzle Linux - Newbie 2 07-12-2005 04:19 PM
need help with cron job parthcorp1 Linux - General 2 02-01-2005 11:37 AM
"permission denied" error when cron job executes jillu Linux - Newbie 11 11-02-2004 01:19 PM
cron job ? johnyy Linux - Software 3 12-10-2003 06:00 PM


All times are GMT -5. The time now is 12:27 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