ISPConfig 3 cron jobs not working

Discussion in 'General' started by misuv, Sep 12, 2013.

  1. till

    till Super Moderator Staff Member ISPConfig Developer

    full cron is fine. If you switch to chrooted cron, then you would have to install a php bianyr into the jail first.
     
  2. orasis

    orasis Member

    oh I see that is very useful info.

    well the Chrooted Cron doesn't like me. Using Fast-CGI and the contents of the /etc/cron.d/ispc_chrooted_web2 are these now:
    Code:
    MAILTO=''
    SHELL='/usr/sbin/jk_chrootsh'
    
    *       *       *       *       *       web2    /usr/bin/php /web/index.php #aaaaa.aa
    
    what should I check ? thanks.

    EDIT:
    oh ! I see...
    But I think it's more secure than Full ?
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    This cant work.you can easily verify this on your harddisk:

    your cronjob instructs linux to run the command:

    /usr/bin/php /web/index.php

    in the jail:

    /var/www/clients/client1/web2/

    so if you add the paths, the following two files must exist:

    /var/www/clients/client1/web2/usr/bin/php

    and

    /var/www/clients/client1/web2/web/index.php

    while its likely that the index.php file exists, I doubt that you have installed the php binary into the jail with jailkit. without a php in the jail, php files cant be executed.

    Yes, thats the purpose of the jail. your script and the cronjob can not leave the directory /var/www/clients/client1/web2/. So all files that are not in subdirectories of /var/www/clients/client1/web2/ are not accessible.
     
  4. orasis

    orasis Member

    Yeah kinda similar to open_basedir, but you guessed well, I don't have php installed in jail. If you have any tutorial for that I'd love to follow it.

    By the way, you explained it very well how those paths work here.
     
  5. orasis

    orasis Member

    although /var/www/clients/client1/web2/usr/bin/php does exist.
    there are 38 files in the /var/www/clients/client1/web2/usr/bin/ directory.

    Code:
    [email protected]:/# ls -l /var/www/clients/client1/web2/usr/bin/
    total 12512
    lrwxrwxrwx 1 root root      21 Nov  7 19:11 awk -> /etc/alternatives/awk
    -rwxr-xr-x 3 root root   30252 Jan 26  2013 basename
    -rwxr-xr-x 3 root root    5552 Jun 27  2012 clear
    -rwxr-xr-x 3 root root   42592 Jan 26  2013 cut
    -rwxr-xr-x 3 root root   38480 Jan 26  2013 dircolors
    -rwxr-xr-x 3 root root   30252 Jan 26  2013 dirname
    -rwxr-xr-x 3 root root  108284 Jan 26  2013 du
    -rwxr-xr-x 3 root root  162424 Jan  6  2012 find
    lrwxrwxrwx 1 root root      21 Nov  7 19:11 ftp -> /etc/alternatives/ftp
    -rwxr-xr-x 3 root root   30280 Jan 26  2013 groups
    -rwxr-xr-x 3 root root   42572 Jan 26  2013 head
    -rwxr-xr-x 3 root root  108100 Jul 27 13:17 host
    -rwxr-xr-x 3 root root   34396 Jan 26  2013 id
    -rwxr-xr-x 3 root root    5272 Dec 30  2012 ldd
    lrwxrwxrwx 1 root root       9 Nov  7 19:11 less -> /bin/less
    lrwxrwxrwx 1 root root      13 Nov  7 19:11 lesspipe -> /bin/lesspipe
    -rwxr-xr-x 3 root root  106908 Mar 24  2012 mawk
    -rwxr-xr-x 3 root root   38484 Jan 26  2013 md5sum
    lrwxrwxrwx 1 root root       9 Nov  7 19:11 nano -> /bin/nano
    -rwxr-xr-x 3 root root   82340 May 25  2012 netkit-ftp
    -rwxr-xr-x 3 root root   30264 Jan 26  2013 nice
    -rwxr-xr-x 4 root root 1487332 Sep 29 17:14 perl
    lrwxrwxrwx 1 root root      21 Nov  7 19:11 php -> /etc/alternatives/php
    -rwxr-xr-x 3 root root 8019476 Oct  5 19:38 php5
    lrwxrwxrwx 1 root root      22 Nov  7 19:11 pico -> /etc/alternatives/pico
    -rwxr-xr-x 3 root root  394796 Dec  2  2012 rsync
    -rwxr-xr-x 3 root root   62848 Feb  8  2013 scp
    -rwxr-xr-x 3 root root  100352 Jan 26  2013 sort
    -rwxr-xr-x 3 root root  440816 Feb  8  2013 ssh
    -rwxr-xr-x 3 root root   34400 Jan 26  2013 tac
    -rwxr-xr-x 3 root root   63140 Jan 26  2013 tail
    -rwxr-xr-x 3 root root   46668 Jan 26  2013 tr
    lrwxrwxrwx 1 root root      20 Nov  7 19:11 vi -> /etc/alternatives/vi
    -rwxr-xr-x 3 root root  730004 Feb 10  2013 vim.tiny
    -rwxr-xr-x 3 root root   18288 Mar 29  2013 watch
    -rwxr-xr-x 3 root root   38524 Jan 26  2013 wc
    -rwxr-xr-x 3 root root  374300 Apr 10  2012 wget
    -rwxr-xr-x 3 root root   30256 Jan 26  2013 whoami
    [email protected]:/# 
    
    
     
    Last edited: Nov 7, 2013
  6. misuv

    misuv New Member

    I can protect the file using .htaccess :D
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The easiest way to find out whats wrong is to create a jailed shell user in this site, then ligin with that user and run:

    /usr/bin/php /web/index.php

    to see the output. It might be that e.g. a loadable modue for php is mising in the jail or something similar.
     
  8. orasis

    orasis Member

    Thanks till for the help, I will check it out now, I am on the server and doing some simialr tests.

    check the previous posts, the problem is easy to solve. avoid the url method (my opinion).
     
  9. misuv

    misuv New Member

    Hurray

    After all this I did the following tests:

    test 1:

    cron command: /usr/bin/php -q web/crono/test_ok.php
    file start with #!/usr/bin/php -q
    script is executed
    error: email is not sent to confirm job executed

    test 2:

    cron command: /usr/bin/php -q web/crono/test_ok.php
    file start with <?php
    script is executed
    error: email is not sent to confirm job executed

    test 3: (an extra / before web)

    cron command: /usr/bin/php -q /web/crono/test_ok.php
    file start with #!/usr/bin/php -q
    script is NOT executed
    email to confirm job executed is sent
    error: Could not open input file: /web/crono/test_ok.php

    test 4: (an extra / before web)

    cron command: /usr/bin/php -q /web/crono/test_ok.php
    file start with <?php
    script is NOT executed
    email to confirm job executed is sent
    error: Could not open input file: /web/crono/test_ok.php

    test 5:

    cron command: /usr/bin/php -q /var/www/clients/client1/web/crono/test_ok.php
    file start with #!/usr/bin/php -q
    script is NOT executed
    error: email is not sent to confirm job executed

    test 6:

    cron command: /usr/bin/php -q /var/www/clients/client1/web/crono/test_ok.php
    file start with <?php
    script is NOT executed
    error: email is not sent to confirm job executed

    test 8:

    cron command: /usr/bin/php web/crono/test_ok.php
    file start with #!/usr/bin/php -q
    script is executed
    error: email is not sent to confirm job executed

    test 9:

    cron command: /usr/bin/php web/crono/test_ok.php
    file start with <?php
    script is executed
    error: email is not sent to confirm job executed

    IN CONCLUSION:

    1. I used this tutorial to install server: The Perfect Server - Debian Wheezy (Apache2, BIND, Dovecot, ISPConfig 3)
    2. The server is a existing PC on LAN not a virtual machine
    3. I can't use wget for cron because LAN is behind a router and redirect me to the router page
    4. cron job is a regular php file
    5. file is copied in web folder (because I intend to use relative paths)
    6. working path from ISPConfig GUI for cron is /usr/bin/php web/path-to-file/cron-file.php
    7. file start with <?php
    8. cron job is executed

    Problems:
    1. ISPconfig don't have an option to add email report to cron job (as Cpanel), maybe it should
    2. if you add an email to cron job, email is sent only if there are errors, if the script is executed, email is not sent

    Thank you and my Lord Jesus Christ bless you all.
     
    Last edited: Nov 8, 2013
  10. orasis

    orasis Member

    ok so !
    it works either way, I just now completely understood how things should be set with each case.

    I set for the client to be 'Chrooted Cron'.
    Then logged in as that client and created a shell user and set 'Chroot Shell' to 'Jailkit'.

    Then created a cronjob and used relative path in the command like this:
    /usr/bin/php /web/index.php

    Now the secret was to also use relative paths in the script. So in index.php that I previously had:
    Code:
    <?php
    file_put_contents('/var/www/clients/client1/web3/web/works.txt', '');
    
    I changed it to:
    Code:
    <?php
    file_put_contents('/web/works.txt', '');
    
    that worked excellent.

    Some things I noticed:

    Loggin in to shell and executing:
    Code:
    /usr/bin/php /web/index.php
    .. with the above settings works as it would with the cronjob
    but If I set the shell user 'Chroot Shell' to 'None',
    .. if I login to shell I see all /web3/ contents and if I run:
    Code:
    /usr/bin/php /web/index.php
    I get an error that it doesn't exist, but If I run:
    Code:
    /usr/bin/php web/index.php
    (without the forward slash before the dir 'web') it works (but using full paths and not relative).

    Conclusion, it works either way, I prefer the 'Chroot Shell' to 'Jailkit' for most security.

    EDIT:
    Also, a shell user that belong to client0 cannot execute a cronjob with 'Chroot Shell' to 'Jailkit'
    Code:
    $ /usr/bin/php /web/test.php
    bash: /usr/bin/php: No such file or directory
    
     
    Last edited: Nov 8, 2013
  11. orasis

    orasis Member

    I am behind a router on lan same as you and everything works excellent.
    You are missing some setting somewhere.
    Check your /etc/resolv.conf to use the server ip first,
    (I have made several installations on debian and everytime my /etc/resolv.conf had nameserver 192.168.1.254 right after install was finished, which is my router gateway, I had to remove this each time)
    check your client computer network settings to use server ip (lan ip) first (to get the dns from server).
    you may need to create a dns entry for this on your server.

    I can run domains and sites on browser such as http://test.test or https://aaaaaaaa.aa
    those are given from the server dns (for each site you need a dns entry to go with it) :)
     
    Last edited: Nov 8, 2013
  12. Nelson Luis

    Nelson Luis New Member

    Bom dia pessoal vocês que estão tendo problemas com o cronjob no ispconfig. Eu já tentei todas as formas de soluções se soluciona-lo através dos fórum dos Estados Unidos e outros países, pensei que fosse um bug no ispconfig. A única forma de solucionar esse problema quando o ispconfig está atrás de um roteador é configurando o dns primário do roteador para direcionar para o IP do servidor Ispconfig e colocar o DNS secundário para um servidor DNS do google como por exemplo 8.8.8.8 ou 8.8.4.4. Reinicie o seu modem e o servidor e pronto agorar o cronjob estará funcionando. Atenção compartilhem essa solução pois tem várias pessoas com o mesmo problema e não estão consegundo solucionado. Este problema foi solucionado por Nelson email: nelluisc @ gmai l. com


    Good morning you who are having trouble with the cronjob in ispconfig. I've tried all kinds of solutions to solve it by the United States and other countries forum, I thought it was a bug in ispconfig. The only way to solve this problem when the ispconfig is behind a router is configuring the primary router dns to point the IP ISPConfig server and put the secondary DNS for a google DNS server such as 8.8.8.8 or 8.8. 4.4. Restart your modem and the server and ready agorar the cronjob is working. Attention to share this solution because it has several people with the same problem and are not consegundo solved. This problem was solved by Nelson email: nelluisc @ gmai l. com
     
  13. Poliman

    Poliman Member

    I have a problem with send email after setup cronjob in ISP. I added some cron under ISP. After this content was created in file /etc/cron.d/ispc_web28. In it is:
    Code:
    MAILTO=''
    SHELL='/bin/sh'
    */5     *       *       *       *       web28   /usr/bin/php /var/www/clients/client11/web28/web/public/admin/cron.php ActivationEmail >>/var/www/clients/client11/web28/private/cron.log 2>>/var/www/clients/client11/web28/private/cron_error.log #example.com
    
    
    I put mail in MAILTO=[email protected] and it's not working. Cronjobs work properly.
     

Share This Page