Check to see if python script is running up vote 8 down vote favorite 7 share [g+] share [fb] share [tw] I have a python daemon running as a part of my web app/ How can I quickly check (using python) if my daemon is running and, if not, launch it? I want to do it that way to fix any crashes of the daemon, and so the script does not have to be run manually, it will automatically run as soon as it is called and then stay running. How can i check (using python) if my script is running?Monitor and restart Apache or lighttpd webserver when daemon is killed by VIVEK GITE on NOVEMBER 21, 2006 · 46 COMMENTS When you cannot monitor your server for service availability, it is better to take help of automated monitor and restart utility. Last 4 days I was away from my server as I was enjoying my vacation. During this time due to load my lighttpd webserver died but it was restarted automatically within 2 minutes. I had utility configured for monitoring services on a Linux system called monit. It offers all features you ever needed for system monitoring and perform error recovery for UNIX like system. Before monit I had my own shell and perl script for monitoring service. If service failed script will try to restart service and send an automated email to me. However monit is a superior solution. monit is a utility for managing and monitoring processes, files, directories and devices on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. For example, monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses to much resources. You may use monit to monitor files, directories and devices for changes, such as timestamps changes, checksum changes or size changes. You may also use monit to monitor files, directories and devices on localhost. Monit can monitor these items for changes, such as timestamps changes, checksum changes or size changes. This is also useful for security reasons you can monitor the md5 checksum of files that should not change. Personally, I always install and configure monit on all boxes which are under my control. Install monit under Debian or Ubuntu Linux Use apt-get command to install monit # apt-get install monit OR $ sudo apt-get install monit Install monit under Red Hat enterprise Linux / CentOS Linux (source code installation) Many distributions include monit. However monit is not included in official Red hat enterprise Linux. Just download monit source code from official web site using wget command: # cd /opt # wget http://www.tildeslash.com/monit/dist/monit-4.8.2.tar.gz Untar monit # tar -zxvf monit-4.8.2.tar.gz # cd monit-4.8.2 Configure and compile monit: # ./configure # make Install monit # make install Copy monit configuration file: # cp monitrc /etc/monitrc By default monit is located at /usr/local/bin/monit How do I Configure monit? monitrc is name of monit configuration file and it is by default located at /etc/monitrc location. However each distribution places file in different location: . => Source code installation : /etc/monitrc => Debian / Unentu Linux installation : /etc/monit/monitrc Open monit configuration file and setup values as follows: # vi /etc/monitrc a) Run it as daemon and check the services (such as web, mysql, sshd) at 2-minute intervals. set daemon 120 b) Set syslog logging with the 'daemon' facility:

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。