Cron jobs for php scripts..

Status
Not open for further replies.
With sweat dripping down my back I managed to log in with the "Terminal" (not the Console as mentioned above) and I got these results:

cat /usr/local/directadmin/custombuild/options.conf | grep php
#PHP settings. default_php possible values - 4 or 5, php5_ver - 5.2 or 5.3
default_php=5
php5_ver=5.2
php4_cli=no
php4_cgi=no
php5_cli=yes
php5_cgi=no
phpmyadmin=yes
php6_cli=no
php6_cgi=no
php_ini=no
php_ini_type=recommended​
whereis php
php: /usr/local/bin/php /usr/local/lib/php /usr/local/lib/php.ini​
php -v
PHP 5.2.13 (cli) (built: Nov 13 2010 14:40:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies​
It sais CLI all over the place so if I'm not mistaken this should work:

/usr/local/bin/php /home/user/domains/mydomain.com/public_html/directory/file.php

I must be mistaken cause it doesn't. It was the first command I tried. If I enter it in my Terminal directly I get no output. However, when I echo some text in the php file the terminal returns that text.

But still no mail and nothing in the cron log.
 
Hold it, I found it, I think. Something's wrong with the file. I tried another one and seems to works. At least the script in the file triggers by the cronjob and runs perfectly but I get no notification from the server and there is nothing in the cron log. These were the signals I was counting on.

Now to figure out why one script runs and the other doesn't.
 
Aah it has been working all the time. I was counting on getting an email or something in the cron log. Now I emptied the database tables and have the script do it's job and it just works with the first line I tried:
/usr/local/bin/php /home/user/domains/mydomain.com/public_html/directory/file.php

Shouldn't I get some email notification or find something in the cron log?
 
If your script, running with cron, outputs nothing, and no error occurs no email will be send on crontask.

On CentOS every cron task is logged when executing in /var/log/cron or /var/log/messages.
 
PHP Cron job problem Help plz

Hi People im new in direcadmin
so i put everything i have for best help answer
this is my cron code:


define('_OW_', true);

define('DS', DIRECTORY_SEPARATOR);

define('OW_DIR_ROOT', substr(dirname(__FILE__), 0, - strlen('ow_cron')));

define('OW_CRON', true);

$_SERVER['REQUEST_URI'] = ''; // just a hack that kills the annoying notice

require_once(OW_DIR_ROOT . 'ow_includes' . DS . 'init.php');

$application = OW_Application::getInstance();

$application->init();

$plugins = BOL_PluginService::getInstance()->findActivePlugins();

foreach ( $plugins as $plugin )
{
/* @var $plugin BOL_Plugin */
$pluginRootDir = OW::getPluginManager()->getPlugin($plugin->getKey())->getRootDir();
if ( file_exists($pluginRootDir . DS . 'cron.php') )
{
include $pluginRootDir . DS . 'cron.php';
$className = strtoupper($plugin->getKey()) . '_Cron';
$cron = new $className;

$runJobs = array();
$newRunJobDtos = array();

foreach ( BOL_CronService::getInstance()->findJobList() as $runJob )
{
/* @var $runJob BOL_CronJob */
$runJobs[$runJob->methodName] = $runJob->runStamp;
}

$jobs = $cron->getJobList();

foreach ( $jobs as $job => $interval )
{
$methodName = $className . '::' . $job;
$runStamp = ( isset($runJobs[$methodName]) ) ? $runJobs[$methodName] : 0;
$currentStamp = time();
if ( ( $currentStamp - $runStamp ) > ( $interval * 60 ) )
{
$cron->$job();

$runJobDto = new BOL_CronJob();
$runJobDto->methodName = $methodName;
$runJobDto->runStamp = $currentStamp;
$newRunJobDtos[] = $runJobDto;
}
}

if ( count($newRunJobDtos) > 0 )
{
BOL_CronService::getInstance()->batchSave($newRunJobDtos);
}
}
}


i need its run every 1 min for ever
what code i must put is cronjob tab?
thnx guys for helping
 
is this php? if yes save as a .php file and add crontab like this

Code:
1/* * * * * /usr/local/bin/php PATH OF YOUR SCRIPT /dev/null 2>&1

Regards
 
Hi thnx for answer
yes its php
i do this
*/1 * * * * /usr/local/bin/php -q /home/royta/domains/royta.ir/public_html/ow_cron/run.php/dev/null 2>&1
but its not work:(
 
i test "-q" and "" too but still not work
my code is work but cron job not run it
 
Code:
*/1 * * * *  >/dev/null 2>&1

For test that your script is working just run manually try this command line

Code:
/usr/local/bin/php /home/royta/domains/royta.ir/public_html/ow_cron/run.php

Regards
 
Status
Not open for further replies.
Back
Top