• Welcome to DNForum.com - Domain Investor Forum, Free Domain Marketplace and a community for 45+ domain pros
    If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the oldest global domain name community on the internet and continues to grow every day. There are over 45,000 domainers on DNForum doing everything from buying domains, selling domains, using our free in-house built tools, learning about domains and discussing domains. Take a minute and Register.

Linux Users?

Status
Not open for further replies.

amplify

Level 5
Legacy Exclusive Member
Joined
Sep 15, 2009
Messages
3,479
Reaction score
1,189
From what I remember using an ampersand at the end of a command in terminal (root) will keep the process running, it even assigns a process number for it. I keep the connection alive just in case.

I found a solution of NOHUP command so that I can exit the terminal, but sometimes it times out, connection is lost and the ampersand will still run the process in the background... so is NOHUP necessary or was was it another process that stopped my scripts? (Is there an error log for why a process stopped?)

Last night Windows Update updated my machine, possibly causing a force log out rather than a timeout...

To keep the script running no matter what, which is better (CentOS):

/usr/bin/php -n -d ... -d ... /path_to_file.php &

or

nohup /usr/bin/php -n -d ... -d ... /path_to_file.php

To keep the process(es) alive no matter what?

I can't seem to find why & stops the process on a forced log out or anything on nohup with running a php script... :?:

I blame Windows for losing me $50 last night. Can I sue them for their shitty automatic update? :approve:
 
The ampersand will keep the process running in the background.

I would guess that your PHP scripts is getting stuck at some point because of stale connections. Perhaps an additional bit of error handling is needed.

What I do for certain cron jobs is, redirect the output (stdout + stderr) to a log file like this:
/bin/somecommand 2>&1 >> logfile

So you can see trace the activity of your script and possibly see when it stops working.
 
With the -n arg I'm dismissing php.ini and -d args I'm using maximum resources and maximum execution time, so I'm puzzled as to why the ampersand won't keep it in the background on the exit of a terminal. I'm not familiar with NOHUP, so don't want to do test runs to get it right as I'm too far into it and it can lead to reduced income.

If anyone has a perfect solution to keep it running, that would be appreciated.

@Katherine, I'll add it to one of the processes (running 4 consecutively, can play around with 1) to see when it quits (wasn't sure if /php would create an error log)... but will it give me a PHP error or system error as to why it was stopped?
 
This should work:

nohup php file.php > /dev/null &
 
Ok, was unfamilier with NOHUP. I'll incorporate that into one of the processes and see if the other 3 die and it lives on. I'm using full processing power of 1 dual core server to calculate a formula for world peace which could get me the Nobel Prize winnings of $1,000,000. :approve:

So far, I've come up with nothing but a hundred dollars though... ;)
 
Perfect solution Theo. Was able to close the connection and they are still running (they all stopped during a Skype call, so figured I'd run it all at once). Also, I was able to add a 5th process. :)

Load Averages: 8.05 3.40 1.29
Load Averages: 9.87 5.62 2.36

...the system may kill one, never seen these numbers! :smilewinkgrin:

I bet she's running hot (but they're scrapping the server once migration is "done").
 
Glad it worked. The server load isn't really indicative of CPU's ability to crunch through the task, it's an overall number that involves I/O throughput, RAM performance etc. You're best suited running heavy tasks on a local machine though, than over the Internet.
 
Status
Not open for further replies.
Back
Top Bottom