Jump to content

php-cli in background


RobertP

Recommended Posts

It really varies by hosting company.

 

I used to work for a company that hosted sites for other companies on FreeBSD.  PHP cli on FreeBSD was "php -r", which is a single-line CLI tool used via SSH.  When run via cron, scripts used /usr/local/bin/php -q, generally.

 

I program for a company now that uses a California hosting company running either RedHat or CentOS.  There I have access to "php -a" for interactive work via SSH, and cron runs scripts from /usr/bin/php, with or without "-q" (doesn't seem to matter for some reason).

Link to comment
Share on other sites

  • 2 weeks later...

I have developed lots of cli programs that run from cron.  There is also at.  However, when you use the word background, this has a special meaning.  I have lots of tasks that are started by cron and then use exec. The secret is to use *nix shell's built in ability to background a process using &.

 

exec('/usr/bin/php -f somescript.php &');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.