Asked  7 Months ago    Answers:  5   Viewed   39 times

I'm trying to run a php-script on a scheduled basis. So I'd thought crontab was a good idea. The server I'm using is on Linux which I'm not that familiar with. So the problem I'm having is, I don't know how make the script executable from php. I need to reference the script, or put it into a folder that can run php from the command line. So I don't know what path to give my crontab, for example:

5  * * * * var/www/some/path/script.php

I found some vague information about this php executable being found in

/usr/bin/php

But I can't find any php file in there, maybe I don't have it installed? My php5 and apache installation is in:

/etc/php5

So my question becomes, is there anyway to execute a php-script with crontab in any other folder, or do I just lack the php executable in usr/bin/php?

 Answers

28

Start by typing at a command line:

whereis php

Do this as the user that the cron job will be run under. This will show you the path to your executable. You can then use that path (if it's not already in your PATH variable) in your cron entry:

5 * * * * /your/path/to/php /var/www/some/path/script.php

Edit: you may need to install the php5-cli (Ubuntu package name) package if all you have is the Apache PHP module installed. This will give you the binary executable that you can run from a command line.

Wednesday, March 31, 2021
 
tpow
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
28

From the man page:

Commands are executed by cron(8) when the minute, hour, and month of year fields match the current time, and when at least one of the two day fields (day of month, or day of week) matches the current time (see ``Note'' below).

and later:

Note: The day of a command's execution can be specified by two fields -- day of month, and day of week. If both fields are restricted (ie, are not *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.

In other words, your script runs on the 1st through the 7th as well as any Sunday.

Wednesday, March 31, 2021
 
Viralk
answered 7 Months ago
81

There should not be a space between "*" and "/10". It should be:

*/10 * * * * /usr/bin/php  /home/user/public_html/domain.com/private/update.php
Thursday, July 29, 2021
 
Ula
answered 3 Months ago
Ula
40

You cannot call JavaScript from within PHP itself. PHP is not a JavaScript engine.

However, there is a PECL Extension for interfacing with V8:

  • http://php.net/manual/en/book.v8js.php
  • http://we-love-php.blogspot.de/2012/07/using-v8-javascript-engine-as-php.html

And you can interface with a (serverside) JavaScript engine. Have a look at node.js and

  • Recommendation for integrating nodejs with php application
Wednesday, August 4, 2021
 
SuperString
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :