The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED WHMAPI1 works from SSH, but not in CRON job

Discussion in 'cPanel Developers' started by domeneas, May 31, 2017.

Tags:
  1. domeneas

    domeneas Active Member

    Joined:
    Sep 20, 2013
    Messages:
    30
    Likes Received:
    2
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    I wrote a script that tells me what users have sent more than X emails in X time when they pass a threshhold.

    I use ($file2 contains a UNIX timestamp):

    while IFS= read -r file2
    do
    whmapi1 emailtrack_user_stats starttime $file2 > email_success_data.txt
    done < email_success_time.txt

    to dump the data to a file. I can run my whole script in SSH by running the main .sh file and it's beautiful. Great little email and phone app reports of possible outgoing spam.

    When I run it via a CRON job though, it returns:

    /root/email_success.sh: line 9: whmapi1: command not found

    Any fixes out there? Something I don't know about WHMAPI1?

    Thanks.
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,493
    Likes Received:
    31
    Trophy Points:
    308
    cPanel Access Level:
    Root Administrator
    The whmapi1 binary is not in the PATH environment used by cron. You can fix this in one of two ways:

    1. Add the whmapi1 directory path to PATH in either cron or your script; or
    2. Use the full path to the whmap1 binary in your script
     
    cPanelMichael likes this.
  3. domeneas

    domeneas Active Member

    Joined:
    Sep 20, 2013
    Messages:
    30
    Likes Received:
    2
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Thanks, spot on.

    which whmapi1

    gave me the path and I just added that to the script and called it directly.
     
    Infopro likes this.
Loading...

Share This Page