need help with cron jobs

Discussion in 'Installation/Configuration' started by gso6, Aug 31, 2014.

  1. gso6

    gso6 New Member

    need help with cron jobs please

    Hi and many thanks already to this website for its VERY GOOD tutorials (The Perfect Server :cool:).
    I'm now with Debian 7.6 and Ispconfig 3.0.5.4p3.

    I'm desperately trying to configure a cron job with jailkit that would run a pg_backup_rotated.sh script that makes a backup of a postgresql database in a defined folder.

    Here are parameters I have set :

    In Client/Clients/Limits
    /SSH-Chroot Options : Jailkit
    /Max. Allowed Cronjob types (chrooted and full implies url) : Chrooted Cron

    In Sites/Cron Jobs/Command to run : /var/www/clients/client1/web1/backup/bdd/pg_backup_rotated.sh

    In System/Server Config/Jailkit/Jailkit chrooted applications : /var/www/clients/client1/web1/backup/bdd/pg_backup_rotated.sh
    In System/Server Config/Jailkit/Jailkit cron chrooted applications : /var/www/clients/client1/web1/backup/bdd/pg_backup_rotated.sh

    Do I have to put the script in both or just in "Jailkit cron chrooted applications" is enough?

    I also created a shell user thinking it could do the trick (not sure it's necessary)
    In Shell-User/Options/Dir : /var/www/clients/client1/web1

    I ran the script as root and it's writing files in /var/www/clients/client1/web1/backup/bdd/files/ as expected but when run by cron, nothing...

    and I see the job in syslog.

    I'm less and less new to Linux and Ispconfig but still, I feel like I'm walking in the dark so I'd very much appreciate your help.

    Good day
     
    Last edited: Aug 31, 2014
  2. gso6

    gso6 New Member

    anyone?

    please, can someone only tell me if my settings in Ispconfig are the way to run a cron job within a jail or am I wrong somewhere?
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    If you use a chrooted cronjob, then the / directory of the jail is /var/www/clients/client1/web1/ So the cron command has to be then:

    /backup/bdd/pg_backup_rotated.sh

    Please undo all changes that you made under System > server config
     
  4. gso6

    gso6 New Member

    no luck

    Thx for your concern,

    still no results.

    I changed the cron job command to :
    /backup/bdd/pg_backup_rotated.sh > /backup/bdd/cron.log 2>&1
    so I could track what's going on.

    It returned "/bin/bash: /backup/bdd/pg_backup_rotated.sh: Permission denied"

    Indeed it was owned by root, so I chowned it to web1

    And now nothing in cron.log but nothing written by the script either.

    Tried redirecting echos within the script to a second log file >> nothing.

    I don't get it, the path to the script is right, and the cron job runs it, but it seems the script isn't parsed...

    I also reinstalled jailkit with last version and reconfigured ispconfig services via update.php (as seen in another thread).

    Any other suggestion?
     
  5. gso6

    gso6 New Member

    progress

    I found that my script wouldn't load a file in its own directory. It has to be referred to with the absolute path starting at web1/ (why?)
    So now I have this in my cron.log:

    id: cannot find name for user ID 5004
    /backup/bdd/pg_backup_rotated.sh: line 43: [: too many arguments
    /backup/bdd/pg_backup_rotated.sh: line 173: expr: command not found
    find: `/var/www/clients/client1/web1/backup/bdd/files/': No such file or directory
    mkdir: cannot create directory `/var/www/clients/client1/web1/backup/bdd/files': Permission denied




    I logged into the shell with the chrooted shell user I created in ISPC.
    The directory tree is as follow :
    /
    |-backup/ (where I find the whole content of /var/www/...../web1/backup/)
    |-web/ (where I find the whole content of /var/www/...../web1/web/)
    |-home/
    ----myshelluser/ (where I find the 2 log files I created)
    ----web1/ (where I find nothing)
    |-var/
    ----run/
    ----www/
    --------clients/
    ------------client1/
    ----------------web1/
    ---------------------backup/
    --------------------------bdd/
    ------------------------------pg_backup_rotated.sh

    I don't know much about jailkit but I have the feeling something is missing in /var/www...
    YES or NO ?
     
    Last edited: Sep 2, 2014
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Why did you put your backup script here?
    |-var/
    ----run/
    ----www/
    --------clients/
    ------------client1/
    ----------------web1/
    ---------------------backup/
    --------------------------bdd/
    ------------------------------pg_backup_rotated.sh

    does not make much sense to me as this will result in a real path:

    /var/www/clients/client1/web1/backup/bdd/var/www/clients/client1/web1/backup/bdd/pg_backup_rotated.sh

    Just put your backup script into the private folder of the website. From within the hjail, the path will be: /private/pg_backup_rotated.sh

    and this path can be used in the cron command as well.
     
  7. gso6

    gso6 New Member

    Thought I could use /bakcup folder for backups other than ISPC's.
    So I put my script there via ftp.

    Now everything is in /private and I get this in my cron.log :

    id: cannot find name for user ID 5004
    /private/backup/bdd/pg_backup_rotated.sh: line 43: [: too many arguments
    /private/backup/bdd/pg_backup_rotated.sh: line 173: expr: command not found
    /private/backup/bdd/pg_backup_rotated.sh: line 97: psql: command not found
    /private/backup/bdd/pg_backup_rotated.sh: line 68: psql: command not found
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    seems as if your script is using commands that are not installed in this jail.
     
  9. gso6

    gso6 New Member

    I think so too.
    How do I do that?
    Isn't it in : server config/jailkit/Jailkit chrooted applications ?
     
  10. gso6

    gso6 New Member

    or should I run as root :
    jk_cp -j /var/www/clients/client1/web1/home/mychrootuser /usr/bin/psql
    jk_cp -j /var/www/clients/client1/web1/home/mychrootuser /usr/bin/expr
     
  11. gso6

    gso6 New Member

    Hi Till,
    thank you for your help until now but I still need you :eek:

    Tried changing "server config/jailkit/Jailkit chrooted applications" but it didn't do anything so

    I read again your first answer and I ran the command (without /home/mychrootuser) :
    jk_cp -j /var/www/clients/client1/web1/ /usr/bin/expr

    Copying /usr/bin/expr to /var/www/clients/client1/web1/usr/bin/expr


    jk_cp -j /var/www/clients/client1/web1/ /usr/bin/psql

    Creating symlink /var/www/clients/client1/web1/usr/bin/psql to ../share/postgresql-common/pg_wrapper
    Copying /usr/share/postgresql-common/pg_wrapper to /var/www/clients/client1/web1/usr/share/postgresql-common/pg_wrapper
    ldd returns non existing library un for /usr/share/postgresql-common/pg_wrapper
    ldd returns non existing library un for /usr/bin/psql

    So everything's fine for expr but not for psql

    Here's what I have in my log file

    id: cannot find name for user ID 5004
    /private/backup/bdd/pg_backup_rotated.sh: line 43: [: too many arguments
    Can't locate POSIX.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/bin/psql line 21.
    BEGIN failed--compilation aborted at /usr/bin/psql line 21.
    Can't locate POSIX.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/bin/psql line 21.
    BEGIN failed--compilation aborted at /usr/bin/psql line 21.

    What do you think I'm doing wrong please?

    Also I checked in /var/www/clients/client1/web1/etc/passwd and found old SSH users I previously deleted in ISPC and a web1 user as follow :

    root:x:0:0:root:/root:/bin/bash
    web1:x:5004:5005::/home/web1:/bin/bash
    oldchrootuser1:x:5004:5005:::/bin/bash
    oldchrootuser2:x:5004:5005:::/bin/bash
    newchrootuser:x:5004:5005:::/bin/bash

    Should I delete oldchrootusers and web1? I'm thinking that's why I'm getting "id: cannot find name for user ID 5004".
    And should I give newchrootuser a home directory?

    I'd really appreciate a little more help please...
     
  12. gso6

    gso6 New Member

    I give up on jailkit for now. Thanks Till anyway.

    I found that bastille-firewall wasn't working, restarting it gave me an error with libkmod could not open moddep file '/lib/modules/

    Found that my kernel was a custom OVH kernel with grsecurity which blocks certain modules so I installed a standard debian kernel and bastille worked.

    I'm pretty sure that jailkit fails to work because of this to...
    Maybe one day we'll see.

    I guess ISPC works better on a std debian kernel.
     

Share This Page