#!/bin/sh sleep 1000 & PID=$!
echo "Waiting for process $PID" sleep 10 kill $PID On Fri, Oct 17, 2008 at 10:47 AM, Philip Serracino Inglott <[EMAIL PROTECTED] > wrote: > I guess that ps was listing the process itself and the grep command > which contains the word "whatareyoudoing" in its command line. > > Anyway, why not put the PID of the process in a file and then at > startup check if that PID belongs to a running process. its much > safer. I can't remember the syntax for this, but I'm sure there's some > script in /etc/init.d that does this trick. > > Philip > > PS if you are on a debain based system (like ubuntu) there is the > start-stop-daemon command that can help > > 2008/10/16 Andrew Cilia <[EMAIL PROTECTED]>: > > Actually the -h failed. arrgh. non-compatible sysv format > > > > On Thu, 2008-10-16 at 18:21 +0200, Andrew Cilia wrote: > > > > Veerrry Veerry close but not quite. I added a '-h' to the ps and it looks > > good now. We still haven't figured out what is wrong yet though. Header > or > > no header, the grep would have taken that out. I'm suspecting some > leftover > > junk from procfs that hasn't been cleaned out yet before ps fetches the > info > > because if you do it in steps, the problem goes away. > > > > Who's going to strace this first? > > > > On Thu, 2008-10-16 at 10:18 +0200, Raphael Borg Ellul Vincenti wrote: > > > > Oh.... don't I luv bashisms ... > > > > I slightly rewrote the program and will explain why > > > > #!/bin/bash > > # -C just gives you a list of the processes called what are you doing > which > > is more efficient than running multiple greps > > # In this case wc -l should always return at least one line since ps -C > > displays a header even when no processes exist > > cntr=$(/bin/ps -C whatareyoudoing | wc -l) > > #make sure cntr is not empty > > if [ "x$cntr" != "x" -a $cntr -gt 1 ]; > > then > > zenity --info --text "Call Logger Is Already Running" > > exit 1 > > fi > > while true > > do > > sleep 15m > > NOW=`date +"%Y|%m|%d|%H|%M|%S"` > > echo $NOW "|" `zenity --text "Attivita' :$NOW" --entry --title "X'Qed > > Tagħmel Man?" --width 1000 --height 5` >> $HOME/CALLOG & > > done > > > > exit 0 > > > > Did that help ? > > > > > > On Thu, Oct 16, 2008 at 10:09 AM, Andrew Cilia <[EMAIL PROTECTED]> > wrote: > > > > Hiyall, > > here's a curious one. I created a batch job called whatareyoudoing > > which contains the text you see below. It should be a simple mechanism > which > > asks the user what they are doing every 15 minutes and has a safeguard > so > > that it does not run more than once. The problem is that the very first > time > > I run it, it's saying that it's running twice. This one has stumped me. > Has > > anyone found anything similar?? > > > > #!/bin/bash > > cntr=`/bin/ps ax | /bin/grep whatareyoudoing | /bin/grep -v grep | wc -l` > > if [ $cntr -gt 1 ]; > > then > > zenity --info --text "Call Logger Is Already Running" > > exit 1 > > fi > > while true > > do > > sleep 15m > > NOW=`date +"%Y|%m|%d|%H|%M|%S"` > > echo $NOW "|" `zenity --text "Attivita' :$NOW" --entry --title "X'Qed > > Tagħmel Man?" --width 1000 --height 5` >> $HOME/CALLOG & > > done > > > > > > > > > > The information contained in this email is confidential and may be > > privileged. It is intended for the addressee only, if you are not the > > intended recipient please notify the sender and delete the email > > immediately. The contents of this email must not be disclosed or copied > > without the senders consent. > > We cannot accept any responsibility for viruses. > > Any views expressed in this message are those of the individual sender, > > except where the sender specifically states them to be the view of Philip > > Toledo Limited > > > > > > > > _______________________________________________ > > MLUG-list mailing list > > [email protected] > > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list > > > > > > > > _______________________________________________ > > MLUG-list mailing list > > [email protected] > > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list > > > > > > The information contained in this email is confidential and may be > > privileged. It is intended for the addressee only, if you are not the > > intended recipient please notify the sender and delete the email > > immediately. The contents of this email must not be disclosed or copied > > without the senders consent. > > We cannot accept any responsibility for viruses. > > Any views expressed in this message are those of the individual sender, > > except where the sender specifically states them to be the view of Philip > > Toledo Limited > > > > _______________________________________________ > > MLUG-list mailing list > > [email protected] > > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list > > > > The information contained in this email is confidential and may be > > privileged. It is intended for the addressee only, if you are not the > > intended recipient please notify the sender and delete the email > > immediately. The contents of this email must not be disclosed or copied > > without the senders consent. > > We cannot accept any responsibility for viruses. > > Any views expressed in this message are those of the individual sender, > > except where the sender specifically states them to be the view of Philip > > Toledo Limited > > > > _______________________________________________ > > MLUG-list mailing list > > [email protected] > > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list > > > > > _______________________________________________ > MLUG-list mailing list > [email protected] > http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list >
_______________________________________________ MLUG-list mailing list [email protected] http://linux.org.mt/cgi-bin/mailman/listinfo/mlug-list

