Shell Script to Auto Run PHP Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell Script to Auto Run PHP Script
# 1  
Old 08-28-2008
Shell Script to Auto Run PHP Script

Hello All!

I am looking to build a monitoring script.

The script should always run as a system service of some type and should always check that a PHP script is running.

Maybe there is a way to assign a PHP script to a certain PID so that the monitor script that check for the PID in top and then if the PID does not exist, then have it run the PHP script.

Basically, I have built a PHP script the constantly monitors two sets of databases to verify that they remain the same and if one DB changes it writes it to the other.
There are MANY MANY reasons for it be done this way versus other possible ways. Mainly because of other functions this script does that due to lots of fun legal paperwork I can't disclose.

So, all in all...
Need a bash/shell script that will constantly check for my PHP script to make sure it is running and make it run if it doesn't exist.

I'm just tired of having a putty window open and my internet dieing and killing the script.

Any help or pointing in the right direction would be of tremendous help.
Thank you for your time!!!
# 2  
Old 08-28-2008
# 3  
Old 08-28-2008
Quote:
Originally Posted by elDeuce

I'm just tired of having a putty window open and my internet dieing and killing the script.
besides what era said. if im not reading this wrong, then you dont know about "nohup" or "screen"

they both have (in different ways) the ability to launch a program/script and they wont die when you close the putty session
# 4  
Old 08-28-2008
Thank you era for those two scripts, I think I should be able to come up with something handy off of those.

No, I had not heard of nohup or screen, but maybe something like that will work for other processes. My deal is that I don't want the process to die unknowingly.

Is it possible to have a PHP script always pull the exact same PID?

Thanks!
# 5  
Old 08-28-2008
But as noted elsewhere, if keeping things running is really important, cron is better than screen or nohup, because it will recover even if the system runs out of resources and kills, say, your process monitoring process. (Of course, if your cron daemon is killed, you are pretty much beyond hope ...)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Shell Script for Auto IP Change

Hi, I am newbie to Linux/Asterisk. I am trying to write a shell script that would look for my SIP trunk registration, if found UNREACHABLE then it would execute a command and check my local IP, if my local IP is 192.168.1.106 then it would change the IP to 192.168.1.150 and vice versa, after... (8 Replies)
Discussion started by: jeetz
8 Replies

3. Shell Programming and Scripting

php file unable to run shell script with arguments

echo $result=exec("./permit.sh".$_FILES); pls suggest some other method to run shell script in php .:wall::mad: (0 Replies)
Discussion started by: upvan111
0 Replies

4. Shell Programming and Scripting

Dry run php script from shell

Is it possible to dry run a php script without actually executing it? Say I need to test the output of a php file to see if it matches a pattern. I need to run this on all php files on the server. But I fear if there are php files that make modifications, sends out mail etc, that should not happen.... (1 Reply)
Discussion started by: anilcliff
1 Replies

5. Shell Programming and Scripting

Script to run php script on multiple website domains

Good Day, I have multiple websites on a domain. I am looking for a loop structure that can run each site script. egdomain1/test.php domainx/test.php so on, currently I copy and paste a list of commands but that skips certain commands. Some help would be greatly appreciated. Sergio (3 Replies)
Discussion started by: SergioP
3 Replies

6. Shell Programming and Scripting

Auto run script on USB device

Okay I want to write a script that I put on a jump drive. And when you plug the USB in this script executes. How would i go about doing this? I don't care what the program does right now. I just want to know how this would be done. Any ideas? (1 Reply)
Discussion started by: cbreiny
1 Replies

7. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

8. Shell Programming and Scripting

Cannot run Shell script in PHP

Hello, I have written a code for uploading a file onto the server.The code is as follows: <? if ($_POST == "Upload File") { if( move_uploaded_file ($_FILES ,$target) ) { $tmpsrc = $_FILES ; echo... (2 Replies)
Discussion started by: michrods
2 Replies

9. Shell Programming and Scripting

Call shell script from php not run ?

Hi. I write a shell script for import data to oracle using sql loader. I set permission 755 or 777 for that script. I can run that script in the consol okay. When I call it from PHP using system command. I got return value 126 this value when don't have permission right ? I check step... (2 Replies)
Discussion started by: raccsdl
2 Replies
Login or Register to Ask a Question