Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Script errors?

Discussion in 'cPanel Developers' started by ARWEB, Feb 17, 2011.

  1. ARWEB

    ARWEB Member

    Joined:
    Jul 19, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    51
    I want to know why if I make a script with .sh type and run it by ssh and works ok without errors, why if I put it in crontab give me errors?
    checarga.sh: line 7: service: command not found
    checarga.sh: line 8: service: command not found


    This is my script checarga.sh:
    #!/bin/bash
    #
    carga=$(cut -f1 -d' ' /proc/loadavg)
    carga=$(echo $carga | bc | sed 's/[.].*//')

    if [ $carga -gt 15 ]; then
    service mysql restart
    service crond restart
    fi

    Could somebody help me? Thank you very much.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Did you put it into root crontab? A user likely cannot run such a script and it would require root level access to do it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. ARWEB

    ARWEB Member

    Joined:
    Jul 19, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    51
    Of course Tristan, I do all with root user by SSH, so???
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If this is in /var/spool/cron/root file as a root user cron and returning that error, then try the following in the script instead for lines 7 and 8:

    Code:
    /etc/init.d/mysql restart
    /etc/init.d/crond restart
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. ARWEB

    ARWEB Member

    Joined:
    Jul 19, 2007
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    51
    Thank you Tristan, script's working now.

    Have a nice day and God bless you.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice