Re: [Hampshire] Cron script spawning too many programs?
On Wed, Mar 4, 2009 at 20:37:57 + (+), AdamC wrote: > Can anyone think of a reason why when cron executes a script many more > programs start (at least over 5), but when I run the script from a > shell, I get the correct amount of programs running that I am > expecting? won't you need to nohup (or disown) the programs otherwise I think the shell kicked off by cron might stick around until the torrents have finished downloading. Adrian -- Email: adr...@smop.co.uk -*- GPG key available on public key servers Debian GNU/Linux - the maintainable distribution -*- www.debian.org -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
2009/3/4 Keith Edmunds : > On Wed, 4 Mar 2009 20:50:52 +, st...@steve.org.uk said: > >> 2. Cron runs. Again - goto 1a. > > Unlikely: he's only running it once per 24 hours. > > Adam: when you say you get a "lot more btdownloadcurses running", what > files are they downloading? The same ones multiple times? Completely the > wrong ones? > > Like Hugo, I suspect this is running in the wrong directory. Putting a > "cd /path/to/dir" at the start of the file will help. Putting in > debug-type info will help more. Not tested, but something like: > > > #!/bin/sh > LOG="/usr/bin/logger -t mycronscript" > > cd /to/my/directory > > LOG "Starting" > > for i in *.torrent > do > LOG "Processing $i" > /usr/bin/btdownloadcurses $i > /dev/null & > done > LOG "Finished" > > > You can, of course, add more LOG statements as required. The LOG > statements will all appear in syslog (or messages or wherever you have > configured those things to go). > > Keith > -- Keith, this log file proved useful - it shows that the cron job only processes the two .torrent files I have in that directory. I'm looking through the output of the set command, although I'm not familiar with this and am not sure what I should be looking for. For some strange reason, rtorrent isn't running from the cron job (or it is, but it's running very quickly). From the sound of it, rtorrent is the preferred way. Adam -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On Wed, 4 Mar 2009 21:01:36 +, k...@midnighthax.com said: Bugger. Missed off the $ signs: > > #!/bin/sh > LOG="/usr/bin/logger -t mycronscript" > > cd /to/my/directory > > $LOG "Starting" > > for i in *.torrent > do > $LOG "Processing $i" > /usr/bin/btdownloadcurses $i > /dev/null & > done > $LOG "Finished" > -- Keith Edmunds +-+ |Tiger Computing Ltd| Helping businesses make the most of Linux | | "The Linux Specialists" | http://www.tiger-computing.co.uk | +-+ -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On Wed Mar 04, 2009 at 20:59:29 +, Alan Pope wrote: > Or use a different tool. > rtorrent *.torrent > > will open one copy of rtorrent rather than having multiple copies of a > bittorrent client running Indeed. My rtorrent installation is configured to auto-start any .torrent file it finds in ~/rtorrent/watch : # ~/.rtorrentrc # # Watch a directory for new torrents, and stop those that have been # deleted. # schedule = watch_directory,5,5,load_start=/home/skx/rtorrent/watch/*.torrent schedule = untied_directory,5,5,stop_untied= Steve -- -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On Wed, 4 Mar 2009 20:50:52 +, st...@steve.org.uk said: > 2. Cron runs. Again - goto 1a. Unlikely: he's only running it once per 24 hours. Adam: when you say you get a "lot more btdownloadcurses running", what files are they downloading? The same ones multiple times? Completely the wrong ones? Like Hugo, I suspect this is running in the wrong directory. Putting a "cd /path/to/dir" at the start of the file will help. Putting in debug-type info will help more. Not tested, but something like: #!/bin/sh LOG="/usr/bin/logger -t mycronscript" cd /to/my/directory LOG "Starting" for i in *.torrent do LOG "Processing $i" /usr/bin/btdownloadcurses $i > /dev/null & done LOG "Finished" You can, of course, add more LOG statements as required. The LOG statements will all appear in syslog (or messages or wherever you have configured those things to go). Keith -- Keith Edmunds +-+ |Tiger Computing Ltd| Helping businesses make the most of Linux | | "The Linux Specialists" | http://www.tiger-computing.co.uk | +-+ -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On 04/03/2009, Steve Kemp wrote: > Solution? Make sure that you only start once for each file. Maybe > something like this: > Or use a different tool. rtorrent *.torrent will open one copy of rtorrent rather than having multiple copies of a bittorrent client running There used to be btdownloadmanycurses which does much the same, but I don't know what happened to that. Cheers, Al. -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On Wed Mar 04, 2009 at 20:37:57 +, AdamC wrote: > Can anyone think of a reason why when cron executes a script many more > programs start (at least over 5), but when I run the script from a > shell, I get the correct amount of programs running that I am > expecting? 1. Cron runs. 1a. Cronjob finds *.torrent 1b. btdownloadcurses starts for each file. 2. Cron runs. Again - goto 1a. Solution? Make sure that you only start once for each file. Maybe something like this: (Notice I've removed the $(ls ..) seems redundant ) #!/bin/sh # start in correct dir cd /home/skx/torrents/spool # find *.torrent for i in *.torrent; do # if not already running start up if [ ! -e $i.working ]; then #create marker so this file is ignored by # next run of cron touch $i.working # download /usr/bin/btdownloadcurses $i > /dev/null & fi done Steve -- Stop blog&forum spam http://blogspam.net/ -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
2009/3/4 Keir Whitlock : > How often is the cron set to run? Does the btdownloadcurses remove the > .torrent file when it processes it? Could the cron be processing the same > torrent file more than once, as it is still in the directory its looking in? > > just a thought. > > Keir Once a night - 18 22 * * 1,2,3,4,5,6 /usr/local/samba/public/cron-torrents/btdownload.sh Thanks Adam -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
On Wed, Mar 04, 2009 at 08:37:57PM +, AdamC wrote: > Can anyone think of a reason why when cron executes a script many more > programs start (at least over 5), but when I run the script from a > shell, I get the correct amount of programs running that I am > expecting? > > I have a small script (see below) that scans a directory for .torrent > files and then starts a btdownloadcurses instance for each file. If I > start the script from the shell, and I have 2 .torrent files in that > directory, then I get 2 instances of btdownloadcurses running. > > However, if cron runs this script then I get a lot more > btdownloadcurses running than I expected and it pretty much makes the > nslu2 crawl along (until I manage to kill the processes). > > Any thoughts what might be going on here? cron usually runs with a severely restricted set of environment variables. Try printing out the environment in the script (with "set") and seeing if there's anything in there that would affect it. My guess is that it's running in the wrong directory. Hugo. -- === Hugo Mills: h...@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- We demand rigidly defined areas of doubt and uncertainty! --- signature.asc Description: Digital signature -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] Cron script spawning too many programs?
How often is the cron set to run? Does the btdownloadcurses remove the .torrent file when it processes it? Could the cron be processing the same torrent file more than once, as it is still in the directory its looking in? just a thought. Keir AdamC wrote: Can anyone think of a reason why when cron executes a script many more programs start (at least over 5), but when I run the script from a shell, I get the correct amount of programs running that I am expecting? I have a small script (see below) that scans a directory for .torrent files and then starts a btdownloadcurses instance for each file. If I start the script from the shell, and I have 2 .torrent files in that directory, then I get 2 instances of btdownloadcurses running. However, if cron runs this script then I get a lot more btdownloadcurses running than I expected and it pretty much makes the nslu2 crawl along (until I manage to kill the processes). Any thoughts what might be going on here? Thanks Adam #!/bin/sh for i in $(ls *.torrent); do /usr/bin/btdownloadcurses $i > /dev/null & done -- Keir Whitlock BEng(hons), MSc, RHCE Mob: 07738681577 E-mail: k...@whitlockweb.net Web: www.keirwhitlock.com GnuPGP Public Key: -BEGIN PGP PUBLIC KEY BLOCK- Version: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ABojzePhjdrg9cwyFhMaUZ8bosgDS YPtj/6Nbae6E6SltLX7q4gbx9CEOkn92Aag8QdxCzf2ISQQYEQIACQUCSaq+tAIb DAAKCRDpHghc0iKSmfUtAKCHnXyxZvGyxNysG2MNvodwWCYNLQCcDwrRDBXzNJgF U4b0EgTSFX+6yIY= =OZnF -END PGP PUBLIC KEY BLOCK- smime.p7s Description: S/MIME Cryptographic Signature -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --