LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   script does not work with crond (https://www.linuxquestions.org/questions/slackware-14/script-does-not-work-with-crond-158011/)

michael_util 03-15-2004 12:29 PM

script does not work with crond
 
Hello,

I have a cron entry that does not work correctly but the commands work fine when I run them manually.

I have a cron entry:
##### Squid access log update
01 06 * * * /home/squid/squidaccessupdate 1> /dev/null
01 12 * * * /home/squid/squidaccessupdate 1> /dev/null
01 18 * * * /home/squid/squidaccessupdate 1> /dev/null

I then have the following script:
--snip--
#!/bin/bash

echo "Starting FTP backup move"

cd /home/squid/logs

echo "open -u mis,WatchdB 192.168.7.8
cd htdocs/datafiles/squid/logs
put access.log" > /tmp/lftp.cmds
echo "quit" >> /tmp/lftp.cmds

/usr/bin/lftp -f /tmp/lftp.cmds 2> /tmp/lftp.error

if [ "$?" == "0" ]; then
echo "File moved successfully"
#/home/friendly/email "Successfully LFTP'ed from $HOSTNAME" /dev/null
else
echo "Error ... file was not moved"
/home/friendly/email "ERROR on $HOSTNAME" /tmp/lftp.error
fi

exit
--snip--

Everytime the cron runs the script the FTP connection does not close, it will stay open until a timeout. If I run ./squidaccessupdate from the command line it works with out a problem.

Anyone got any ideas.

horndude 03-15-2004 01:27 PM

Add a line at the end to close the connection.

michael_util 03-15-2004 01:58 PM

The script works when I execute it, the lftp.cmds command file, which holds all the commands that get run has the following:

open -u username,password IP
cd htdocs/datafiles/squid/logs
put access.log
quit

So the connection does get closed.

michael_util 03-15-2004 02:04 PM

Hello,

I removed the "exit" from the bottem of the script and it seemed to fix the issue.

Michael.


All times are GMT -5. The time now is 08:06 PM.