Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
I have a script that moves completed torrents to a completed folder running every 30 minutes. But, I don't want this to run if Transmission Daemon is not running. Can anyone just post a simple if then script to check to see if it's running and I will encase my current script in the if,then sript?
I was thinking the command being like this, but I'm unsure of the syntax:
$running = `ps | grep transmission | wc -l`
if $running gt 1; then
{my script here}
fi
Will that work? I am assuming when I run the grep command it will create a process called "grep transmission" so I will need the wc -l to be greater than 1.
Thanks in advance
Offline
Although that may work, another option is simply to call the transmission start script with a "status" parameter.
On the flip side, what's the big deal about whether it is running or not? I have a script that checks every hour to see if there are any completed torrents, it then removes the torrent (keeping the data). If there is nothing to do, it runs quick ![]()
You may be able to modify this perl script to do what you want.
#!/ffp/bin/perl
#
# trans_cleanup.pl perl script that removes completed torrents
# tr_port is the port that transmission admin is running on
$tr_port = 9090;
# tr_bin is the path and name of transmission-remote executable
$tr_bin="/ffp/bin/transmission-remote";
$tdate = `/ffp/bin/date`;
chomp($tdate);
# Strip the timezone to match the Transmission date entry
# This is EDT and EST in my case
$tdate =~ s/E.T //ig;
#print $tdate." Running $0\n";
# query for any completed torrents
@trn_items=`$tr_bin $tr_port -l|grep "Finished"`;
foreach $item(@trn_items) {
$item =~ s/^\s+//;
while ( $item =~ m/ / ) { $item =~ s/ / /ig; }
@b = split(/\s/,$item);
$tname = $b[9];
for ($i=10; $i<=($#b+1); $i++) { $tname .= " ".$b[$i]; }
print $tdate." Removal of torrent [".$b[0]."] ".$tname;
# delete the finished torrent entry
$result = `$tr_bin $tr_port -t $b[0] -r`;
chomp($result);
print ( $result =~ m/success/i ? "succeeded\n" : "FAILED ".$result."\n" );
}
# eofLast edited by FunFiler (2010-12-16 02:47:48)
Offline
I was just trying trying to eliminate the need to spin up the disks. But then again, running ANY script from /ffp and down requires a disk to spin up, right? So I guess I'm not accomplishing much if this "new" script is located in /ffp too...
Offline
bound4h wrote:
I was just trying trying to eliminate the need to spin up the disks. But then again, running ANY script from /ffp and down requires a disk to spin up, right? So I guess I'm not accomplishing much if this "new" script is located in /ffp too...
I'm not super-clear on that myself.
If you have a real simple script that runs in a loop and sleeps for a period of time to do something every 30 mins or whatever, it may not need the disk once it is loaded and running. Of course a lot depends on what the work part of the script actually does. If it accesses the disk to look at a file or something, then the disk will start.
If you have something like a perl script (#!/ffp/bin/perl in first line), like in this thread, the disk will probably spin up whenever it runs. This is because the perl interpreter is in /ffp and so are a lot of libraries that the script may need which may get loaded dynamically as the script runs.
Note that if you use cron to launch a script periodically from /ffp then the disk will probably start for that as well. But I think you can use cron to launch a simple script that is itself stored on the ramdisk and does not touch the disks without spinning up the disk.
I know some people here were working on a Dynamic DNS script that could run from cron without starting the disk. A script like this needs to run every 10 mins or so. One problem with one of the "standard" DNS update scripts is that it is written in perl and so causes a disk access every time it starts. I think that there is a thread in this forum someplace where people were working on a non-perl script that would not start the disks.
Offline
You can do it easier:
if ps | grep -v grep | grep transmission ; then # Your code here fi
The first grep will filter out grep, the result of the second grep will be evaluted by 'if'
About spinning up the disk, when you didn't install coreutils, all commands used are actually busybox, which is already loaded in memory (The shell running your script is also busybox). The same instance of busybox will be reused, so nothing has to be loaded from disk.
You could also run your script with firmware commands. These are in rom.
shan't
Offline