Find the answer to your Linux question:
Results 1 to 3 of 3
a=$(df -h /mnt/smb | tail -n +3 | tr -s ' ' | tr '%' ' ' | cut -d ' ' -f 5) echo $a if [[ $a -ge ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2014
    Posts
    15

    sendmail command with cron job.


    a=$(df -h /mnt/smb | tail -n +3 | tr -s ' ' | tr '%' ' ' | cut -d ' ' -f 5)
    echo $a

    if [[ $a -ge 30 ]]; then
    cat /etc/diskspace/text.txt | sendmail test.gmail.com
    fi

    Hallo guys
    this is my script and everyhing is working so well acording to my need. i just have one question.

    I want to run this script via cronjob. like every Minutes.

    (* * * * * (. /etc/diskspacae/vpndrive.sh)#--Cron job command.

    As you can see that i want to perform sendmail command that afte running this script if drive space is more than 80%, i get notification in my email .

    But i dont get it when i run this script for cron tab.
    and get this error msg in var/spool/mail /root.

    ERROR Messae: /etc/diskspace/vpndrive.sh line 34 : sendmail: command not found.

    any guess please ?

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,180
    Cron is replacing the PATH variable. You can set the path in /etc/crontab or in your script or use complete paths. Have a look at man crontab.

  3. #3
    Just Joined!
    Join Date
    May 2014
    Posts
    15
    Hallo Guys ,
    Cron job is also throwing now sendmail command.i just put that whole path of sendmail in my script /usr/sbin/sendmail and then it works.

    can someone help me to find it out how can i run my cron job with different user measn now i am getting emails from root and i want that i create user called: Diskspace and send me this email.

    Basically i want to run my cron job with Diskspace user so i get email from not root but from diskspace.
    here is my cron job command.----> 0 0-23/4 * * * (. /etc/diskspace/vpndrive.sh) now i am running with root.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •