LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-23-2004, 02:52 PM   #1
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Rep: Reputation: 0
cron job errors


Ok, I am having some problems with crond and and crontab... here are the details of the setup.

# Line in crontab -l

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

# Contents of dhcp.sh

#!/bin/sh
# dhcp.sh :: restarts dhcp services with custom dhcpd.conf file

today=`date +%m.%d.%Y`
time=`date +%T`
if HOME=/path/to/dhcp/bin
then
if test -f /path/to/dhcp/conf/restart
then
if test -f /path/to/dhcp/conf/dhcpd.conf
then
echo $today - $time
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 /usr/local/www/dhcp/conf/dhcpd.conf
echo `DHCP Service was started successfully.`
echo `/path/to/dhcp/conf/dhcpd.conf`
rm /path/to/dhcp/conf/restart
if test -f /path/to/dhcp/conf/restart
then
rm -dfr /path/to/dhcp/conf/restart
echo `Removal of temporary file failed`
else
echo `Removed file used to flag mandatory restart`
fi
else
echo `DHCP Service was started`
/usr/sbin/dhcpd -cf /path/to/dhcp/conf/dhcpd.conf
rm /path/to/dhcp/conf/restart
echo "----------------------------------------------------------------"
fi
else
echo `File was not found`
fi
else
exit 0
fi
else
exit 0
fi

# the results are to be put in the /tmp/dhcp_log file, this is the line that gets created

/bin/sh: line 1: 1^M: ambiguous redirect

# I start crond with this line so I can see what cron is doing

/usr/sbin/crond -L /tmp/crond_log

# this is the results found in crond_log once crontab runs script

USER root pid 28545 cmd /bin/sh /usr/local/www/dhcp/bin/dhcp.sh &>/tmp/dhcp_log 2>&1

I am not sure what the error:: /bin/sh: line1: 1^M: ambiguous redirect means and how to remedy it. Any help is appreciated!
Jas
 
Old 01-23-2004, 02:55 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
The "^M" suggests that you've been using
a DOS text-editor to create the script ... and
that won't work.


Cheers,
Tink
 
Old 01-23-2004, 02:59 PM   #3
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
Really? I have been using putty to edit the cron.txt I am importing to the crond daemon... hmmm. Is it throwing in a character return or something?
 
Old 01-23-2004, 03:31 PM   #4
existo
LQ Newbie
 
Registered: Jan 2004
Distribution: SlackWare 9.1
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks, that was the one thing I have not been able to find in any newsgroup, thread or man page about using cron. I actually created the file on a windoz box, uploaded it to the linux box and then imported it into cron that way... You solved my problem.
 
Old 01-23-2004, 03:40 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Pleasure mate :}

Feel free to give me an affero if time permits ;}


Cheers,
Tink
 
  


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 job the_rhino Linux - Newbie 10 10-02-2004 04:34 PM
log cron job to capture errors if there are ashley75 Linux - General 1 05-21-2004 11:34 AM
Cron job rajasekarvr Linux - General 4 05-03-2004 06:35 PM
cron job thesnaggle Linux - Newbie 1 09-19-2003 11:47 AM
Cron Job imanahmadi Linux - Newbie 1 07-04-2003 12:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration