Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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

    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/ 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/ line 34 : sendmail: command not found.

    any guess please ?

  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Victoria, B.C. Canada
    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
    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/ now i am running with root.

  4. $spacer_open

Posting Permissions

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