Run cron job with different User
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. |
every user has its own crontab. You can try to use su to change user before executing that script. I do not know how do you send that mail, but you can also try to fake the sender (if it suits your needs)
|
Hallo ,
i have script which check drive space .. 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 | /usr/bin/sendmail Test@gmail.com fi and now i have set this cron job with root user. i just want to set that other user run this cron job. Can you please detail me little bit that how can i set this for another user. or how to access cron job for other user. I need to give some rights to other user also to run sendmail command? |
see man crontab. as root you can edit other users' cronjobs too.
crontab -u user -e |
Hello,
As Pan64 mentions, Quote:
Code:
a=$(df -h /mnt/smb | tail -n +3 | tr -s ' ' | tr '%' ' ' | cut -d ' ' -f 5) Quote:
Regards, Rawcous |
Quote:
Thanks alot man ! it worked fine |
just a comment: the first line will fork 6 processes, that is not a really optimal solution:
Code:
df -m /mnt/smb | awk '/smb/ { if ( $3/$2 > 0.3 ) exit 1 }' || { |
Code:
#!/bin/bash Put the other part in another function then call that function from this one. |
All times are GMT -5. The time now is 11:54 PM. |