I'm not sure i understand you correctly, but I had a similar issue myself when trying to connect from my Windows machine to my Debian machine which was running some websites of mine with ISPConfig3 as admin panel, and i solved it by doing this: If you'r trying to reach the server with ISPConfig3 from a Windows machine you will have to edit the file called "hosts" (located within the "C:\Windows\System32\drivers\etc" directory) and append this: Code: #--- NO ROUTER WEB-GUI START 192.168.100.15 yourdomain.tld #--- NO ROUTER WEB-GUI END Same workaround works for Linux based systems: Edit the file "/etc/hosts" with ie. "nano /etc/hosts" and add following line to the file Code: #--- NO ROUTER WEB-GUI START 192.168.100.15 yourdomain.tld #--- NO ROUTER WEB-GUI END Replace the IP address "192.168.100.15" to the machine's IP that is hosting ISPConfig3 within your local network and the "yourdomain.tld" to the actual site's address that you want it to respond to. And remember to forward the ports 80 (HTTP) and 443 (SSL/HTTPS) to the ISPConfig3 machine. I know this has nothing to do with ISPConfig3 itself, but it will make you able to use the "just type the URL into ISPConfig3 Cron Jobs page, option" instead of having to make all sorts of workarounds into your already existing code just to get it to execute the cronjob with no errors. I hope you understand me.. it can be hard at times
I tried, but is not working I changed the code as sugested and cut off all unnecesarly code: #!/usr/bin/php -q <?php define("DB_SERVER", "***"); // DB server name define("DB_USER", "***"); // DB user define("DB_PASS", "***"); // DB password define("DB_NAME", "***"); // DB name $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS); mysql_set_charset("utf8"); mysql_select_db(DB_NAME, $connection); $date = time(); $text = 'test'; $sql_insert = ' INSERT INTO test '; $sql_insert .= ' ( text , date ) '; $sql_insert .= ' VALUES '; $sql_insert .= ' ( "' . $text . '" , "' . $date . '" ) '; mysql_query($sql_insert, $connection); but is not working, I receive the same error Exception: Zend Extension /var/www/clients/client1/web1/web/crono/test_ok.php does not exist I found the following answer on net, but don't know how to use it: It turned out that this problem was caused by php files that has been uploaded with Windows line endings. Once I corrected the line endings using dos2unix the problem went away. any hint?
Your code now looks fine, as soon as the <?php is stuck on the top of the file. Windows end a line with \r\n when you for example use html to instruct a browser to print the rest on the next line and these characters should not be generated right now from your script as it looks clean. But I do not know why you get this error now. I would try a couple of things. First insert on the top of your script this line: Code: ini_set('zlib.output_compression', 0); and then, in order to troubleshoot your script insert: Code: ini_set('display_errors', 1); ini_set('error_reporting', '-1'); then run the script from the browser and not from a cron job. See if it works and check for errors in all the error logs. It may be an issue with your setup in general and this way you will find out. so your code will look like this: Code: <?php ini_set('zlib.output_compression', 0); ini_set('display_errors', 1); // show all errors (do not use this on a production site) ini_set('error_reporting', '-1'); // report any kind of error (do not use this on a production site) // -------------------------------- define("DB_SERVER", "***"); // DB server name define("DB_USER", "***"); // DB user define("DB_PASS", "***"); // DB password define("DB_NAME", "***"); // DB name $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS); mysql_set_charset("utf8"); mysql_select_db(DB_NAME, $connection); $date = time(); $text = 'test'; $sql_insert = 'INSERT INTO test '; $sql_insert .= ' ( text , date ) '; $sql_insert .= ' VALUES '; $sql_insert .= ' ( "' . $text . '" , "' . $date . '" )'; mysql_query($sql_insert, $connection); Notice I removed the beginning and ending gaps from your $sql_insert variable. I would actually prefer this to be in one line like this: Code: $sql_insert = 'INSERT INTO test (text, date) VALUES ("'.$text.'", "'.$date.'")'; It would be a good idea to check your php.ini settings as well. If this is a windows server or some kind of virtual kind of vmware setup then I would blame that ! EDIT: I forgot to mention, if it works fine on browser and without errors, edit those from this: Code: ini_set('display_errors', 1); ini_set('error_reporting', '-1'); to this: Code: ini_set('display_errors', 0); ini_set('error_reporting', 'E_ALL & ~E_NOTICE'); Now although not related, avoid using constants when not needed. In this case the DB_SERVER, DB_USER etc are only going to be used once in this script and then they are dead constants. So your cron job script should look something like this: Code: <?php ini_set('zlib.output_compression', 0); ini_set('display_errors', 0); ini_set('error_reporting', 'E_ALL & ~E_NOTICE'); // -------------------------------- $db_server = "***"; // DB server name $db_name = "***"; // DB name $db_user = "***"; // DB user $db_pass = "***"; // DB password $connection = mysql_connect($db_server, $db_user, $db_pass); mysql_set_charset('utf8'); mysql_select_db($db_name, $connection); $date = time(); $text = 'test'; $sql_insert = 'INSERT INTO test (text, date) VALUES ("'.$text.'", "'.$date.'")'; mysql_query($sql_insert, $connection); retry the cron job. Good luck !
still same problem thanks orasis, but is not working, I receive the same error the code now is: #!/usr/bin/php -q <?php ini_set('zlib.output_compression', 0); ini_set('display_errors', 1); // show all errors (do not use this on a production site) ini_set('error_reporting', '-1'); // report any kind of error (do not use this on a production site) //ini_set('display_errors', 0); //ini_set('error_reporting', 'E_ALL & ~E_NOTICE'); // -------------------------------- $db_server = '***'; // DB server name $db_name = '***'; // DB name $db_pass = '***'; // DB user $db_user = '***'; // DB password $connection = mysql_connect($db_server, $db_user, $db_pass); mysql_set_charset("utf8"); mysql_select_db($db_name, $connection); $date = time(); $text = date('d-M-Y H:i:s', $date); $sql_insert = 'INSERT INTO test (text, date) VALUES ("'.$text.'", "'.$date.'")'; mysql_query($sql_insert, $connection); The server is a working machine with Debian system. I also changed php.ini as follow: ;output_handler = zlib.output_compression = 4096 zlib.output_compression_level = -1 ;zlib.output_handler = If I run the file from browser is running fine If I run it from CLI : /bin/sh /var/www/clients/client1/web1/web/crono/test_ok.php I receive the following error: : No such file or directoryb1/web/crono/test_ok.php: line 2: ?php /var/www/clients/client1/web1/web/crono/test_ok.php: line 3: syntax error near unexpected token `"zlib.output_compression",' /var/www/clients/client1/web1/web/crono/test_ok.php: line 3: `ini_set("zlib.outp't_compression", 0); if I run the cron job I receive the following error by email: Exception: Zend Extension /var/www/clients/client1/web1/web/crono/test_ok.php does not exist Any other ideas?
Hi, 1.) is the cron job chrooted? If yes, then the path is relative to the web root, i. e. /web/crono/test_ok.php 2.) Try using php instead of "sh" to run the script from command line and make sure you have the php-cli package installed.
1.) the path is fine since the file is executed 2.) if I run from CLI /usr/bin/php /var/www/clients/client1/web1/web/crono/test_ok.php the script is executed ok. the cron job create the following file content: MAILTO='' SHELL='/bin/sh' * * * * * web1 /var/www/clients/client1/web1/web/crono/test_ok.php #smirotour.ro Maybe is some way to set ISPConfig to run cron job as regular php file?
Try changing the command to: /usr/bin/php /var/www/clients/client1/web1/web/crono/test_ok.php (in cron job interface)
why not just do this ? Code: [COLOR=DarkGreen]php /var/www/clients/client1/[/COLOR][COLOR=DarkGreen][COLOR=DarkGreen]web1[/COLOR]/web/[/COLOR][COLOR=DarkGreen][COLOR=DarkGreen]crono[/COLOR]/test_ok.php[/COLOR] can you try in another file this code only ? Code: <?php $file = '/var/www/clients/client1/[COLOR=DarkGreen]web1[/COLOR]/web/[COLOR=DarkGreen]crono[/COLOR]/works.txt'; file_put_contents($file, ''); exit; it should create a 'works.txt' file in your crono dir what editor are you using ?
because cronjobs on a Linux server does not have the PATH variable set in the cron shell, so if you would use just "php /var/www/clients/client1/web1/web/crono/test_ok.php", then the cronjob will never be executed.
sure, I didn't mean in the cronjob, but for the cli. If you see I quoted the '2.) if I run from CLI'.
the cron is looking like this now: MAILTO='' SHELL='/bin/sh' * * * * * /usr/bin/php /var/www/clients/client1/web1/web/crono/test_ok.php but is not working, cron is not executed
I trid what you said from cli its creating works.txt (empty file) from cron I receive the following error: /var/www/clients/client1/web1/web/crono/test.php: line 1: ?php: No such file or directory /var/www/clients/client1/web1/web/crono/test.php: line 2: =: command not found /var/www/clients/client1/web1/web/crono/test.php: line 2: $'\r': command not found /var/www/clients/client1/web1/web/crono/test.php: line 3: syntax error near unexpected token `$file,' /var/www/clients/client1/web1/web/crono/test.php: line 3: `file_put_contents($file, '');' if I add on the first line #!/usr/bin/php -q I receive from cron: Exception: Zend Extension /var/www/clients/client1/web1/web/crono/test.php does not exist in CLI I use nano for php I use netbeans and notepad
I am afraid you will have to use the wget solution in the cron or create an .sh script. I hadn't tested crons on ispconfig before and as I tested yesterday it seams that it only supports sh and wget. I am not sure, Till can give some light on this, but this is what it says in IPSConfig. My tests with php files were only successful using the full url only, although I even gave 755 executable permissions to the php file etc. I didn't get your error though. You can at least try it, remember not to include the 'wget' at all, type the complete url like: http://blahblah.com/script.php only. I think this approach though is a little risky once you must some way protect this file from the public. So I am now also interested to know how to execute php without the use of wget.
I have no problems executing php scripts. You have to enter the command /usr/bin/php -q /var/www/clients/clientX/webY/web/path/cron.php when you set up the cron in ISPConfig. If you are limited to chrooted crons you can NOT use this, until you added php to the chrooted environment. If the chroot has php available the command would be: /usr/bin/php -q /web/path/cron.php
ISPConfig cronjobs are normal linux cronjobs, there is nothing special with them and you can do everything in a ispconfig cronjob that you can do in a normal linux cronjob. Executing php shell scripts works fine, I run many of them on my server. ISPConfig just writes the file in /etc/con.d/, so you can see yourself whats in there, it is the same that you enterd in ispconfig. If a cronjb does not work and the file in /etc/cron.d/ has been written, then its not related to ispconfig. The most common errors were: - you use a wrong path or use no path (I pointed it out above why it is a bad idea to even test with php /path/yourfile.php on the shell, as this test result is irrelevant as a test can be successful even if it must fail as cron) - you use a jailed cronjob and try to execute applications that are not in the jail. Croydon pointed that out in his post above. - you use a jailed cronjob and provie a full system path. In a jail, the / directory is the website root and not the / directory of the server.
nothing, it doesn't do anything. I tried everything. Do I need to some special additional setup ? nothing I tried worked. By the way, is it normal when an admin adds/edits a cronjob or website or setting of a client and then the client cannot change anything to that cronjob.website or even delete it ? Because I just discovered that I was in as admin, created the cronjob for a client to test and when I logged in as client I could not change any setting to that cron or even delete it. Anyway, cronjobs do not work for me.. !
No. Post the cron file of the website from /etc/cron.d/ folder. Yes, thats intended. Tgis way the admin can create locked records. If you want that your client can edit them as if he would have creetd them himself, then use the "login as" function as admin in the client list to become the client before you create the records.
after 1000 attempts and right after I posted my previous reply, I had the idea to remove the -p from the command and it worked. Oh my gosh ! Till, the file contents are these: Code: MAILTO='' SHELL='/bin/sh' * * * * * web2 /usr/bin/php /var/www/clients/client1/web2/web/index.php #aaaaa.aa (notice the domain huh ? huh ? ) That using Full Cron, I got to test also the Chrooted Cron I can agree with what you are saying, but is there some setting to switch that record to the client's permissions ? or some setting to choose if you want it locked or not ? because an admin could forget to login as client and then need to go delete it and re create it etc etc. EDIT: with or without this: Code: #!/usr/bin/php in the beginning of the php file the script executes.
When you use: * * * * * web2 /usr/bin/php /var/www/clients/client1/web2/web/index.php then the php file has to start with <?php, and not with #!/usr/bin/php when you would use this: * * * * * web2 /var/www/clients/client1/web2/web/index.php then the file has to start with #!/usr/bin/php and it must be executable (chmod +x).