Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

Linux Users?

Status
Not open for further replies.

amplify

Level 5
Legacy Exclusive Member
Joined
Sep 15, 2009
Messages
3,480
Reaction score
1,196
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:
 
Dynadot - Expired Domain Auctions

katherine

Country hopper
Legacy Exclusive Member
Joined
Jul 9, 2005
Messages
8,427
Reaction score
1,290
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.
 

amplify

Level 5
Legacy Exclusive Member
Joined
Sep 15, 2009
Messages
3,480
Reaction score
1,196
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?
 

Theo

Account Terminated
Joined
Feb 28, 2004
Messages
30,306
Reaction score
2,216
This should work:

nohup php file.php > /dev/null &
 

amplify

Level 5
Legacy Exclusive Member
Joined
Sep 15, 2009
Messages
3,480
Reaction score
1,196
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... ;)
 

amplify

Level 5
Legacy Exclusive Member
Joined
Sep 15, 2009
Messages
3,480
Reaction score
1,196
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").
 

Theo

Account Terminated
Joined
Feb 28, 2004
Messages
30,306
Reaction score
2,216
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.

Who has viewed this thread (Total: 1) View details

Who has watched this thread (Total: 3) View details

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members Online

Sedo - it.com Premiums

IT.com

Premium Members

MariaBuy

Upcoming events

New Threads

Our Mods' Businesses

UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom