Trouble with CRON job

Discussion in 'Installation/Configuration' started by manarak, Mar 5, 2011.

  1. manarak

    manarak Member

    The client is setup in full cron.

    I have the following script, called chg_vacation_msg, which is located in
    /var/www/clients/client2/web7/autoresponders

    Code:
    #!/bin/bash
    # copy autoresponder msg
    cp /var/www/clients/client2/web7/autoresponders/test.txt /var/vmail/mailfilters/domainname/testaccount/.vacation.msg
    
    If I execute this script under shell, using ./chg_vacation_msg , the file gets copied ok.

    If I do su web7 and execute the script, the file gets copied ok too.

    I put the following in the CRON interface in ISPC3 :
    the log gets created, but is empty, and the file is not copied!

    syslog contains this line:

    /USER/SBIN/CRON (WEB7) CMD (/var/www/clients/client2/web7/autoresponders/chg_vacation_msg)

    but no errors

    I don't know why it doesn't work.
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Please try to use the full path to cp in your script.
     
  3. manarak

    manarak Member

    thanks!
    do you mean /bin/cp or /var/www/clients/client2/web7/bin/cp ?

    the latter would be illogical since the client is setup with full cron, and the first doesn't work, I tried it before.

    anyway, I added the script to /etc/crontab and it works!
    (that's why a crontab form for admin/root under 'system' would make sense)

    but I'd still like to know how I could make it work using ISPC
     
    Last edited: Mar 6, 2011
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Its simply a permission problem, the user web7 has no permission to copy a file to /var/vmail/mailfilters/domainname/testaccount/

    You can not test it like this. If you run su web7, then you remain root user as the web[ID] users dont have a shell that allows to switch with su. Thats why you did not recognize the permission issue.
     
  5. manarak

    manarak Member

    thanks!

    is there any way for admin to setup cron jobs running with user "root" in the ISPC interface?
    This could come handy in some cases, and /etc/crontab can be forgotten if the server gets migrated

    I'm not knowledgable enough to give web7 permissions for the following directory and subdiretories/files:
    /var/vmail/mailfilters/domain.ch

    ...another question is whether the .vacation.msg files should not be located in /var/www/clients/client2/web7 by default, to allow users to change their autoreply messages by script?
     
    Last edited: Mar 7, 2011
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    > is there any way for admin to setup cron jobs running with user "root" in the ISPC interface?

    no.

    Web7 shall not have permissions to these directories. If you would grant web7 access to the mailsystem, then the web7 user would be able to read all messages of all accounts.

    The message belongs to the mail system and not the webserver. ispconfig is a multiserver system, so yoiu can not assume that a webserver and mailserver are on the same system.
     
  7. manarak

    manarak Member

    So it seems a cron job setup by admin was the only easy solution.
     

Share This Page