Linux Send Output To Particular Mail id or File To Maintain The Log Information

[root@rhel5 ~]#ls -l | sendmail jkumaron@gmail.com
[root@rhel5 ~]#chkconfig --list | sendmail -F "List Out all the Server" jkumaron@gmail.com

-F refers To The From Address.
send the mail with the particular text document
sendmail jkumaron@gmail.com < /etc/crontab

Add Entry In cron tab
#0 2,13 * * * /sbin/ping -c 10.0.0.1; ls -la >>/var/log/cronrun
It will execute ping and ls -la  command at 2AM and 1PM and it will put the output of command into the log file /var/log/cronrun

it will store the shell script output to the corresponding file /tmp/backup.log file.

>
Redirect to output
2>
Redirect to error
2>&1
Redirect to error to standard output
<
Redirect to input
|
Pipe standard output to another command
>>
Append to standard output
2>&1|
Pipe standard output and standard error to another command

Post a Comment

0 Comments