I have to run a php file every 5 seconds , and have two issues
1. The file works perfectly when opened in a browser, but running the 'php myfile.php' command fails and produces the following error
PHP Warning: include_once(../tutadmin/config/config.php): failed to open stream: No such file or directory in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Warning: include_once(): Failed opening '../tutadmin/config/config.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/cron/teacher_status_cron.php on line 3
PHP Notice: Use of undefined constant TBL_USER - assumed 'TBL_USER' in /var/www/html/cron/teacher_status_cron.php on line 5
PHP Notice: Use of undefined constant TEACHER_USER_GROUP_ID - assumed 'TEACHER_USER_GROUP_ID' in /var/www/html/cron/teacher_status_cron.php on line 9
PHP Notice: Undefined variable: current_user_id in /var/www/html/cron/teacher_status_cron.php on line 14
PHP Notice: Undefined variable: current_date_time in /var/www/html/cron/teacher_status_cron.php on line 15
PHP Notice: Undefined variable: dbc in /var/www/html/cron/teacher_status_cron.php on line 20
PHP Fatal error: Uncaught Error: Call to a member function Query() on null in /var/www/html/cron/teacher_status_cron.php:20
Stack trace:
#0 {main}
thrown in /var/www/html/cron/teacher_status_cron.php on line 20
Crontab will not run the program every 5 seconds, only every minute at best.
Edit: the file does not work outside of cron in the CLI either, only on a web browser.. Cron is not the issue.
Because you have not right permissions on file, your cron can not open file, change permissions.
Related
I have a project based on Opencart 3+ version on my OpenServer.
Then i try to load my project i have some errors.
Notice: unserialize(): Error at offset 0 of 5 bytes in C:\OpenServer\domains\depotop\admin\index.php on line 46
Notice: unserialize(): Error at offset 0 of 22 bytes in C:\OpenServer\domains\depotop\admin\index.php on line 46
Notice: unserialize(): Error at offset 0 of 9 bytes in C:\OpenServer\domains\depotop\admin\index.php on line 46
Notice: unserialize(): Error at offset 0 of 9 bytes in C:\OpenServer\domains\depotop\admin\index.php on line 46
Notice: unserialize(): Error at offset 0 of 29 bytes in C:\OpenServer\domains\depotop\admin\index.php on line 46
Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in C:\OpenServer\domains\depotop\system\library\session.php on line 7
Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in C:\OpenServer\domains\depotop\system\library\session.php on line 8
Warning: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent in C:\OpenServer\domains\depotop\system\library\session.php on line 10
Warning: session_start(): Cannot start session when headers already sent in C:\OpenServer\domains\depotop\system\library\session.php on line 11
Notice: Undefined index: filename in C:\OpenServer\domains\depotop\admin\index.php on line 123
Notice: Error: Could not load language ! in C:\OpenServer\domains\depotop\system\library\language.php on line 43
Warning: Cannot modify header information - headers already sent by (output started at C:\OpenServer\domains\depotop\admin\index.php:46) in C:\OpenServer\domains\depotop\system\library\currency.php on line 52
Warning: unlink(c:/OpenServer/domains/depotop/system/cache/cache_c21f969b5f03d33d43e04f8f136e7682_7f24d9fc4140045241b3f97bcf36bf03): No such file or directory in C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php on line 608
Warning: include_once(PEAR.php): failed to open stream: No such file or directory in C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php on line 567
Warning: include_once(): Failed opening 'PEAR.php' for inclusion (include_path='C:\OpenServer\domains\depotop\vendor/pear/cache_lite;.') in C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php on line 567
Fatal error: Uncaught Error: Class 'PEAR' not found in C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php:568
Stack trace:
#0 C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php(609): Cache_Lite->raiseError()
#1 C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php(459): Cache_Lite->_unlink()
#2 C:\OpenServer\domains\depotop\admin\model\localisation\currency.php(170): Cache_Lite->remove()
#3 C:\OpenServer\domains\depotop\admin\controller\common\login.php(89): ModelLocalisationCurrency->updateCurrencies()
#4 C:\OpenServer\domains\depotop\system\engine\front.php(42): ControllerCommonLogin->index()
#5 C:\OpenServer\domains\depotop\system\engine\front.php(29): Front->execute()
#6 C:\OpenServer\domains\depotop\admin\index.php(160): Front->dispatch()
#7 {main} thrown in C:\OpenServer\domains\depotop\vendor\pear\cache_lite\Cache\Lite.php on line 568
Pear on my server, 7.4 php version
# pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE VERSION STATE
Archive_Tar 1.4.9 stable
Console_Getopt 1.4.3 stable
PEAR 1.10.12 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.5 stable
Why "Fatal error: Uncaught Error: Class 'PEAR' not found in", how i can fix that?
This error occurs beacuse the file PEAR.php is not found in the given directory. You just include this file. Have you checked, if the file PEAR.php is really in the given path you use with include_once('Pear.php')?
The solution to your problem: Just give the right path to the include function.
I have a cron job that runs daily (for over a year) and suddenly does not work.
I have a cron job that looks like:
/usr/bin/php -q /home/tcanfarotta22/public_html/test_arg.php low_customer=2 high_customer=200
And then a PHP script that gets the variables like:
parse_str($argv[1], $params);
parse_str($argv[2], $params2);
$low_customer = $params['low_customer'];
$high_customer = $params2['high_customer'];
Now I am getting the following errors:
[18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
variable: argv in /home/tcanfarotta22/public_html/test_arg.php on line
5 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
variable: argv in /home/tcanfarotta22/public_html/test_arg.php on line
6 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
index: low_customer in /home/tcanfarotta22/public_html/test_arg.php on
line 8 [18-Jun-2018 10:38:01 America/New_York] PHP Notice: Undefined
index: high_customer in /home/tcanfarotta22/public_html/test_arg.php
on line 9
Nothing has changed so I ma not sure what to do. Does anyone know?
If the enabling of register_argc_argv does not fix the issue, then maybe you are trying to access $argv within a class, in this case, you need to declare it as global before you can access it:
global $argv;
BTW, I have tested your code (executed by the terminal) and it runs like a charm.
If this does not fix the issue, maybe then you need to put more details, also we need to know how you are testing?
I have debian dev server with stock mongodb; php 5.4 and pecl mongodb drivers v1.4.3.
I tried to create simple conntection using PHP Cli and got exception:
php -r "MongoLog::setLevel(MongoLog::ALL); MongoLog::setModule(MongoLog::ALL); new MongoClient('mongodb://127.0.0.1:27017', array());"
the output below:
PHP Notice: PARSE INFO: Parsing mongodb://127.0.0.1:27017 in Command line code on line 1
PHP Notice: PARSE INFO: - Found node: 127.0.0.1:27017 in Command line code on line 1
PHP Notice: PARSE INFO: - Connection type: STANDALONE in Command line code on line 1
PHP Notice: CON INFO: mongo_get_read_write_connection: finding a STANDALONE connection in Command line code on line 1
PHP Notice: CON INFO: connection_create: creating new connection for 127.0.0.1:27017 in Command line code on line 1
PHP Notice: CON INFO: stream_connect: Not establishing SSL for 127.0.0.1:27017 in Command line code on line 1
PHP Notice: CON INFO: get_server_flags: start in Command line code on line 1
PHP Notice: CON FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice: CON FINE: send_packet: data_size: 73 in Command line code on line 1
PHP Notice: CON FINE: get_server_flags: can't find maxBsonObjectSize, defaulting to 4194304 in Command line code on line 1
PHP Notice: CON FINE: get_server_flags: can't find maxMessageSizeBytes, defaulting to 8388608 in Command line code on line 1
PHP Notice: CON INFO: get_server_flags: found server type: UNKNOWN? in Command line code on line 1
PHP Notice: CON INFO: is_ping: pinging 127.0.0.1:27017;-;.;29554 in Command line code on line 1
PHP Notice: CON FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice: CON FINE: send_packet: data_size: 69 in Command line code on line 1
PHP Notice: CON INFO: is_ping: last pinged at 1376577544; time: 0ms in Command line code on line 1
PHP Notice: REPLSET FINE: finding candidate servers in Command line code on line 1
PHP Notice: REPLSET FINE: - all servers in Command line code on line 1
PHP Notice: REPLSET FINE: filter_connections: adding connections: in Command line code on line 1
PHP Notice: REPLSET FINE: filter_connections: done in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by seeded/discovered servers in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by seeded/discovered servers: done in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by credentials in Command line code on line 1
PHP Notice: REPLSET FINE: limiting by credentials: done in Command line code on line 1
PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found' in Command line code:1
Stack trace:
#0 Command line code(1): MongoClient->__construct('mongodb://127.0...', Array)
#1 {main}
thrown in Command line code on line 1
I have found workaround - is downgrade dirver version to 1.3.6; but it is not a solution.
Take a look at: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
I solved my problem after installing 10-gen version mongodb.
Had the same problem today, downgraded to the 1.3.6 version of mongo driver in pecl "worked" for me... System: Debian Squeeze
This does the job for you:
pecl uninstall mongo
pecl install mongo-1.3.6
find i m trying to convert sequence of images into a video. and for that i canme to know about the ffmpeg class.
the only wrapper class that i found is phpvideotoolkit but i m not able to work with it.
i installed phpvideotoolkit on xampp on my windows 2008 server . but it is throwing alor of errors
This example shows you how to extract a specific frame from a movie.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\MOV00007.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\Video000.3gp" was not found. No images were generated.
Notice: Undefined property: PHPVideoToolkit::$_tmb_directory in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 869
Notice: Undefined offset: 0 in C:\xampp\htdocs\phpvideo\phpvideotoolkit.php5.php on line 877
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\to-be-processed\cat.mpeg" was not found. No images were generated.
example
PHPVideoToolkit Error: Execute error. Output for file "C:\xampp\htdocs\phpvideo\examples\working\tmp\1336156630-4fa421d69357d\tmp_%d.jpg" was not found. Please check server write permissions and/or available codecs compiled with FFmpeg. You can check the encode decode availability by inspecting the output array from PHPVideoToolkit::getFFmpegInfo().
i m trying to make it work since last many hours but no luck
Also, for this code :
$srcFile = "test-mpeg.mpg";
$ffmpegObj = new ffmpeg_movie($srcFile);
i am gettign error that it cant file the file. i believe its something to do with permissions but i m not able to figure out
fpoen , fwrite , file_put_contents all are working fine without any permissions problems.
can anyone please guide me in the write direction. what do i need to do to make this phpvideotoolkit work
I have bee trying to get this test to run
require_once 'PHPUnit/Framework.php';
require_once('../config/config.php');
require_once('../classes/division.class.php');
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
{
$division = new division();
try{
$division->createDivisionDetails();
}catch (CustomException $e) {
return;
}
$this->fail('An expected exception has not been raised.');
}
}
on this Command
phpunit --configuration=phpunit.xml division.test.php
but keep geting the error message
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
PHP Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
PHP Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
PHP Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46
I am using a phpunit.xml to try to set the $_SERVER['HTTP_HOST'] but seem like it is not working at all
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<php>
<server name="HTTP_HOST" value="DEV"/>
</php>
</phpunit>
Everything I have read seem to say this should work
The xml looks fine as far as i can see it. Two suggestions:
class DivisionTest extends PHPUnit_Framework_TestCase
{
public function Divisiontest()
i'd change the function name to testDivision() so phpunit picks it up as a real test (the code gets execution because its named like the class (a.k.a. php 4 style constructor) but thats not really optimal)
If that doesn't fix your problem: Does it work when you put
$_SERVER['HTTP_HOST'] = "DEV";
before the
$division = new division();
statement ? Just to make sure the error is that the xml file isn't read and doesn't hide somewhere else