[Tutor] checking for a process
John Moylan
john at rte.ie
Wed Aug 27 09:43:42 EDT 2003
Hi,
I have written a script for Linux that I want to have run from Crontab every 3
minutes. But I don't want to run a new copy of the script if another is still
running. With BASH I would put something like the following at the start of my
script:
if [ -e $PIDFILE ] && ps >/dev/null -p `cat $PIDFILE`; do
exit
else
echo $$ > $PIDFILE
.
.
.
.(script)
.
rm $PIDFILE
The problem is that I don't want to have to create a BASH wrapper script
around my python script ....but I can't find any way of finding out if a
process is running ala the ps bit of my script above...without spawning a
shell. Is there any way to do this natively in Python? or is there a better
way of creating the same functionality in Python?
Kind Regards,
John Moylan
John Moylan
RTE Technology
Donnybrook,
Dublin 4.
+353 1 2083564
******************************************************************************
The information in this e-mail is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this e-mail by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.
Please note that emails to, from and within RTÉ may be subject to the Freedom
of Information Act 1997 and may be liable to disclosure.
******************************************************************************
More information about the Tutor
mailing list