Visit Our UNIX and Linux User Community


Problem with ftp scripts and cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with ftp scripts and cron
# 1  
Old 10-16-2009
Problem with ftp scripts and cron

Need some help / advice with the follow script...

Basically i have an FTP server that connects to other ftp servers and sends and downloads files every few hours or so. There are 12 different accounts that all have 2 scripts each, one to send and one to receive. Below is an example send script for one account. There all the same, just the top variables are changed...

I have put these all in cron to run at certain times but after activating all of them and checking it in the morning it was hanging on connection (ssh)... i managed to get in but was greeted with a number of CRON memory error messages... it seems if the jobs are running into some sort of error they are running again exactly 1min later... how can i stop this???

Any help is appreciated Smilie



Code:
#!/bin/sh
HOST=***
USER="***"
PASS="***"
ACCOUNT=***
REMOTE_DIRECTORY=***
 
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
lcd /home/ftp/$ACCOUNT/ftptransfer/outgoing
cd $REMOTE_DIRECTORY
mput *
bye
EOF
 
# Sends title to log file
echo "-------send-------" >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
 
# Sends date to log file
date >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
# Count how many files are inside outgoing
 
echo "Number of files inside outgoing :" >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
 
ls -l /home/ftp/$ACCOUNT/ftptransfer/outgoing | grep ^- | wc -l >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
 
# List the files that have just been sent
echo "List of files that have just been sent :" >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
ls /home/ftp/$ACCOUNT/ftptransfer/outgoing >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
 
# Moves the files from outgoing to archived
mv /home/ftp/$ACCOUNT/ftptransfer/outgoing/* /home/ftp/$ACCOUNT/ftptransfer/archived
 
# Counts how many files are inside archived
echo "Number of files inside archived :" >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
ls -l /home/ftp/$ACCOUNT/ftptransfer/archived | grep ^- | wc -l >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt
 
# Line break to log file
echo "" >> /home/ftp/$ACCOUNT/ftptransfer/log/log.txt



---------- Post updated at 04:39 AM ---------- Previous update was at 04:33 AM ----------

The error message is along the lines of (sorry i forgot most of it)

out of memory kill process cron score

Last edited by Franklin52; 10-16-2009 at 06:49 AM.. Reason: Please use code tags!
# 2  
Old 10-16-2009
Seems your script is not the reason directly - I would check the free memory of your box, patch level etc. to make sure it isn't be caused because of a bug/memory leak or something like that.
Check the error log of your Unix/Linux too maybe.

Previous Thread | Next Thread
Test Your Knowledge in Computers #368
Difficulty: Medium
The Open Group released the Single UNIX Specification Version 2 in 1987.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

2. AIX

Cron scripts security

Hello everyone, I have an AIX 6.1 machine and i experienced a problem with my cron scripts. It appears that somebody renamed a cron script so crontab could not execute it. Is there a way to put some security on cron scripts so nobody else except root can rename or delete a cron script? Or they... (6 Replies)
Discussion started by: omonoiatis9
6 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script1.php'); system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script2.php'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Solaris

running scripts from cron

I need to run a script (from cron) that runs a second script. What worries me is that second script, when run from bash, upon finishing doesn't return to bash unless I press the 'Enter' key. I presume that's because last command in that script ends with & Could that be a problem for cron?... (2 Replies)
Discussion started by: orange47
2 Replies

5. UNIX for Dummies Questions & Answers

Cron changing folder for scripts

I would like to ask if cron when running a planned script changes the current folder for the script. Thank you! (2 Replies)
Discussion started by: MartyIX
2 Replies

6. Shell Programming and Scripting

Cron and multiple scripts problem.

Hello All, I have 3 scripts namingly 1X 2X and 3X. I have one directory ABC created which contains some 40 sub directories. I have one input file in the below format.The input file resides in ABC directory. Inputfile format; subdirectoryname date subdirectoryname1 date subdirectoryname2... (1 Reply)
Discussion started by: RSC1985
1 Replies

7. Shell Programming and Scripting

Running 2 scripts one after the other using cron

I would like to run two scripts using cron one immediately after the other. Is it enough to put them one after another in the cron file to run at the same time, or will this cause them to run concurrently? (4 Replies)
Discussion started by: 3210
4 Replies

8. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

9. Shell Programming and Scripting

Issue calling scripts through CRON.

I have the following cron job in the crontab. #! /bin/bash 25 15 * * 1-5 /export/home/svittala/scripts/scpt1.sh >/dev/null 2>&1. The problem that I am facing is - the scpt1.sh can be executed manually. But, it is not executing through CRON. Not sure what's the issue. Any hints?. Thanks.... (5 Replies)
Discussion started by: vskr72
5 Replies

10. Shell Programming and Scripting

help in cron scripts

Hi, i have scheduled my scripts in cron, some time the script doesn't runs ..which will impact me a lot, can some one help me such that mail has to come stating script has run successfully/unsuccessful any help will be appreciated.. thanks in advance, geeko (0 Replies)
Discussion started by: geeko
0 Replies

Featured Tech Videos