Hi there I looked over all post I found but I can't find a solution for my problem. I installed a server following this tutorial. Everthing works fine, except cron jobs. I setup a client with full cron & -1 at Max. number of cron jobs & Min. delay between executions and enabled Shell User for this client I can ad cron jobs from panel, both as admin and client. I tried 3 versions for same cron from ispconfig panel, a file ispc_web1 was create in /etc/cron.d# with the following content: MAILTO='' SHELL='/bin/sh' * * * * * web1 /var/www/clients/client1/web/crono/crono-grab-addresses.php #domain.com * * * * * web1 /usr/bin/wget -q -t 1 -T 7200 -O /dev/null 'http://www.domain.com/crono/crono-grab-addresses.php' >/dev/null 2>&1 #domain.com * * * * * web1 /usr/bin/wget http://www.domain.com/crono/crono-grab-addresses.php #domain.com cron log file shows only: PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0 (many times) no cron is executed from server comand line I tried: crontab -u web1 -l And answer is: no crontab for web1 what I'm doing wrong? Help me please!!!!
The cronjobs are stored in /etc/cron.d and not in a crontab. If you want to view them, take a look into the files in /etc/cron.d/. The crontab command is only for editing the crontab and not the crontabs in cron.d. This can not work, the php interpeter is missing. correct would be e.g. /usr/bin/php /var/www/clients/client1/web/crono/crono-grab-addresses.php Thats ok, it will work as long as the script can really be reached under the url: http://www.domain.com/crono/crono-grab-addresses.php
still not working Hi Till thanks for your answer I changed the code as you sugested. 1) the cron jobs are inserted using ISPconfig GUI 2) I checked in /etc/cron.d and I have the folowing files: amavisd-new awstats ispc_web1 mailman php5 3) in ispc_web1 I have: MAILTO='' SHELL='/bin/sh' * * * * * web1 /usr/bin/php /var/www/clients/client1/web/crono/test_ok.php #smirotour.ro 4) if I run command: crontab -u web1 -l I received answer: no crontab for web1 5)the cron is not executed. If I run file manualy is executed any more sugestions?
1-3: ok and as it should be. 4) Ok as well, the user crontab is something different then the files in cron.d, so you an not list the content of cron.d files with the crontab command. 5) Check your syslog file for cron lines.
command tail -f /var/log/ispconfig/cron.log PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf .d/ming.ini on line 1 in Unknown on line 0 script is not executed
Thats the wrong file and not related to user cronjobs. Take a look into the syslog like I suggested above. The syslog is /var/log/syslog
one step ahead Hi till thank you, I start to make progresses. 1) in /var/log/syslog: Sep 17 12:20:01 server1 /USR/SBIN/CRON[5044]: (getmail) CMD (/usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null) Sep 17 12:20:01 server1 /USR/SBIN/CRON[5043]: (root) CMD (/usr/local/ispconfig/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log) Sep 17 12:20:01 server1 /USR/SBIN/CRON[5045]: (web1) CMD (/usr/bin/php /var/www/clients/client1/web/crono/test_ok.php #smirotour.ro) 2) I added a mail report and received the followin message: Cron <web1@server1> /usr/bin/php /var/www/clients/client1/web/crono/test_ok.php #smirotour.ro PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0 Could not open input file: /var/www/clients/client1/web/crono/test_ok.php 3) I tried to change /usr/bin/php with /usr/bin/php5 (as I fount on net), but the result was the same I think the problem is with the path used. on ISPConfig GIU is suggested: e.g. /var/www/clients/client1/myscript.sh or http://www.mydomain.com/path/script.php But when I tried /var/www/clients/client1/web/crono/test_ok.php I received the same result any more sugestions?
Similar Issue Hi Till, i have having the same sort of issue with crons that have stopped working The cron jobs are configured within ISPConfig i have the following logs: cat /var/syslog - Sep 18 10:52:01 CRON[31533]: (web72) CMD (/usr/bin/wget -q -t 1 -T 7200 -O /dev/null 'http://www.domain.com/crons/update_category_suppliercounts.php' >/dev/null 2>&1 #domain.com) /etc/cron.d/ispc_web72 - 22,52 * * * * web72 /usr/bin/wget -q -t 1 -T 7200 -O /dev/null 'http://www.domain.com/crons/update_category_suppliercounts.php' >/dev/null 2>&1 #domain.com ISPConfig site error.log [Wed Sep 18 10:52:01 2013] [error] [client *.*.*.*] client denied by server configuration: /u0/webroot/virtual/clients/client9/web72/web/public_html/crons/update_category_suppliercounts.php The crons can be run from a browser without any issues I cant see where the denied from server configuration comes into play Any help would be greatly appreciated Paul
my recomandation to remove the ming error has nothing to do with your cron problem. it was just a help to remove the error you was reciving from ming.ini so you could focus on the cron problem sorry but the cron problem i dont have a solution to
Hi, I found this topic by performing a search on Google because I was wondering why the cronjobs that I entered on the "Cron Jobs" page within ISPconfig3 doesn't work the way I thought they would. I finally made my 3 cronjobs working by reading the output within /var/log/syslog When entering a cronjob - you need to keep in mind that the command that is being used is either "wget" for URL's entered or "sh" for command line execution. Do not enter any wget or sh in front cause it won't work, they are added automatically. Furthermore, if you enter which site needs to use the cronjob - the path is relative to the website root of the user. So this means: -------------------- URL's are to be entered in this format: http://www.somecronjob.com/somedirectory/cron.php?task=fish Wget is automatically added to the URL that is being requested every given times you want it to run decided from your */5 * * * * fields. -------------------- Command line cronjobs which are run by sh, are to be entered in this format: web/somedirectory/cron.sh?task=fish The path is relative to the root of the Website you choose. Some documentation on the "sh" linux command can be found here: http://linux.about.com/library/cmd/blcmdl1_sh.htm -------------------- I hope this helps some people who might have the same struggles I had to get them working Regards, Kims
1 step ahead thanks Kims I changed the path to web/crono/test_ok.php and now the cron is running or not I had 2 errors: 1) acces denied to file fo cron job I solved this by running the following command: chmod +x /var/www/clients/client1/web1/web/crono/test_ok.php suggested on http://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work?page=1&tab=votes#tab-top But this should have been done by ISPConfig GUI, I think 2) and a problem that I didn't solved and I need help when I run the cron job I receive the following error: --------------------- # /var/www/clients/client1/web1/web/crono/test_ok.php /var/www/clients/client1/web1/web/crono/test_ok.php: line 1: syntax error near unexpected token `(' 'var/www/clients/client1/web1/web/crono/test_ok.php: line 1: `<?php ob_start(); ?> ------------------------ here is the code of my file: ------------------------ <?php ob_start(); ?> <?php defined("DB_SERVER") ? null : define("DB_SERVER", "******"); // DB server name defined("DB_USER") ? null : define("DB_USER", "******"); // DB user defined("DB_PASS") ? null : define("DB_PASS", "******"); // DB password defined("DB_NAME") ? null : define("DB_NAME", "******"); // DB name // // Create a database connection $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS); if (!$connection) { exit('Database connection failed: ' . mysql_error()); } else { // set charset to UTF-8 mysql_set_charset("utf8"); // Select database $db_select = mysql_select_db(DB_NAME, $connection); if (!$db_select) { exit('Database selection failed: ' . mysql_error()); } } ?> <?php function getIP() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet $ip = filter_var(trim($_SERVER['HTTP_CLIENT_IP']), FILTER_VALIDATE_IP); } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy $ip = filter_var(trim($_SERVER['HTTP_X_FORWARDED_FOR']), FILTER_VALIDATE_IP); } else { $ip = filter_var(trim($_SERVER['REMOTE_ADDR']), FILTER_VALIDATE_IP); } if ($ip == '::1') { $ip = '127:0:0:1'; } return $ip; // return empty string if IP is not valid } $date = time(); $text = getIP(); // Create $sql_insert = ' INSERT INTO test '; $sql_insert .= ' ( text , date ) '; $sql_insert .= ' VALUES '; $sql_insert .= ' ( "' . $text . '" , "' . $date . '" ) '; $result_sql_insert = mysql_query($sql_insert, $connection); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result_sql_insert) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $sql_insert; die($message); } $sql_read = ' SELECT * FROM test '; $result_sql_read = mysql_query($sql_read, $connection); // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysql result functions must be used // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while ($row = mysql_fetch_assoc($result_sql_read)) { echo date('d-M-Y H:m:s', $row['date']) . '- ' . $row['text'] . '<br />'; } // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result_sql_read); ?> <?php ob_end_flush(); ?> ------------------------- any help is apreciated Regards Mihai
Hi misuv, Instead of typing the php file into a path for direct execution, try to enter the URL to the php file instead, just like this: http://www.somedomain.com/crono/test_ok.php This will make a wget to the URL and execute the php file as you want it to. It seems to me that when you enter the direct path into the Web GUI (ISPconfig3) it will try to execute the file with the command SH infront and not the php command as you want it to. Try it and see if it helps
Not viable solution Thanks Kims, But the servers is behind a router and can't access himself, it redirect me to ruoter page, so wget is not a solution.
Your problem is not even ispconfig specific. When you want to execute a php script, then you have to do this with the php interpreter. So instead of using this as command: /var/www/clients/client1/web1/web/crono/test_ok.php you use this as command: /usr/bin/php -q /var/www/clients/client1/web1/web/crono/test_ok.php or call it by its URL by entering just: http://yordomain.tld/crono/test_ok.php ind the command field or use wget like Kims suggested. Btw: The more *angry" smileys you put in your posts and post headers, the more unlikely it is that you will get a answer
regarding your second error, does your script work without errors if you run it from the browser and have display_errors on ? I would also recommend not to close and reopen the php tags inside the script for no reason example things like: Code: [COLOR=DarkOliveGreen]<?php ob_start(); ?> <?php defined("DB_SERVER") ? null : define("DB_SERVER", "******"); // DB [/COLOR] would better be: Code: [COLOR=DarkOliveGreen]<?php ob_start(); defined("DB_SERVER") ? null : define("DB_SERVER", "******"); // DB [/COLOR] also another recommendation is not to close the script with a php tag if you got no html or other language to continue. Example your end part: Code: // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result_sql_read); ?> <?php ob_end_flush(); ?> would better be: Code: // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result_sql_read); ob_end_flush(); except characters economy, the most important reason for this is that unexpected characters after a closing tag such as even a space can cause issues with 'headers already sent' etc. cheers
one step ahead Hi everyone thanks for the help so far Now is almost working I added the following first line into my file: #!/usr/bin/php -q And used web/crono/test_ok.php as path in crono job the cron job is executed , but I receive the following error: Exception: Zend Extension /path-to-file.php does not exist any help?
this when in relation to cron jobs is possibly a problem with line-endings such as "\n" characters generated by your code. Try to make the changes to your script file by removing all unneeded open/close php tags as I describe in my previous post