LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash Process not killed when using crontab (https://www.linuxquestions.org/questions/linux-newbie-8/bash-process-not-killed-when-using-crontab-942551/)

BlackLicht 04-30-2012 08:48 AM

Bash Process not killed when using crontab
 
Hi,

I am new to this form and to linux. (Sorry for my English)
I have 5 bash scripts written in bash.
It is a simple script that puts files on the internet, using ftp.
This scripts runs every 5 minutes and one script every 1 minute using crontab.
Code:

#!/bin/sh
# Run the weer update poller every 1 minutes
*/1 * * * * root /home/weerupdatelive.sh > /dev/null 2>&1

The files I put on the internet are not large and in several seconds the are on the internet.
When the script is done, not every time the process is killed.
After a week I have about 400 process running ftp.
Then I must use kill -9 to kill the process.
Is the a easier way to do this or to control the process using a pid file?

The script is simulaitr to this:
Code:

#!/bin/sh
# this script
user=user1@provider.com
password=password
basedir='/web/weergegevens'

ftp -n home.provider.com<<EOF
user ${user} ${password}
lcd ${basedir}
binary
prompt
mput mini_current*.*
mput aktuell*.*
mput instr_*.*
mput client*.txt
send wedaal.txt
send windbft_current.gif
send ws_realtime.txt
send kort.html
send metric.text
send barotrend.gif
send current.html
send custom.html
send datastation.php
send ddis_current.gif
send ddis_f_current.gif
send hetweeractueel.html

When I run this script manual it is done within 20 sec.

druuna 04-30-2012 09:01 AM

Hi and welcome to LQ!

First thing I noticed about the above script:
- the ftp session is not ended (no bye),
- the here-document doesn't end (no closing EOF).

Hope this helps.

BlackLicht 04-30-2012 10:05 AM

Hi and tnx,

I have put the lines at the end of the file.
Is das not help.
Perhaps the FTP session is dead and the jobs is not stoped. (completed')
Not always. It is I think 50/50. Sometimes it stops and sometimes not.

pan64 04-30-2012 11:57 AM

can you show what did you put at the end of the file?

BlackLicht 05-01-2012 03:48 AM

Hi,

This is what I did:
Code:

bye
quit
EOF

Today I have taken a look at the "PS aux |grep ftp" and I see that there are only 19 process still running.
Is is not closed, perhaps hanging?

druuna 05-01-2012 04:08 AM

Hi,
Quote:

Originally Posted by BlackLicht (Post 4667366)
This is what I did:
Code:

bye
quit
EOF


Remove the quit, it isn't needed.

You might also try to add the -i switch to the ftp command:
Code:

ftp -n home.provider.com<<EOF
vs
ftp -in home.provider.com<<EOF

The -i switch turns off interactive prompting during multiple file transfers.

Quote:

Today I have taken a look at the "PS aux |grep ftp" and I see that there are only 19 process still running.
Is is not closed, perhaps hanging?
I'm guessing that the ftp session isn't closed correctly, which will trigger a time-out on a none ftp level, which in turn defuncts the script/ftp process.

Hope this helps.

BlackLicht 05-04-2012 07:22 AM

I have done the changes. Still some running processes. But not 100's.
Also I think that the ftp session is not closed by error or something.
And deleted the line prompt.


All times are GMT -5. The time now is 02:12 PM.