Re: Interactive task scheduling (system) ? How do I run a list of tasks consecutively on a server ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a simple shell script I wrote a long time ago which
is invoked by a CGI script on a local web page and notices
files that show up in a queue directory.

#!/bin/bash

# This script is started by the setuid program start-queue so that the
# CGI script which makes queue entries can have the queue processed
# as the right user.

# If the script detects a copy of itself already running, it exits and
# allows the existing copy to process the new queue entries when it gets
# around to it.

mydir=`dirname $0`
PATH=`$mydir/echo-path`
export PATH

cd $mydir/../queue
if [ -f ".pid" ]
then
   exit 0
fi
echo $$ > .pid
mypid=`cat .pid`
if [ "$$" = "$mypid" ]
then

   # Looks like this instance got here first, start processing the queue

   trap "rm -f .pid" EXIT
   while true
   do
      nextqueue=`ls -1 2>/dev/null | head -1`
      if [ -f "$nextqueue" ]
      then
         handle-queue-entry "$nextqueue"
         rm -f "$nextqueue"
      else
         # We seem to have run out of queue entries to process. Exit now.
         exit 0
      fi
   done
fi
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux