Hello,
I'm trying to create a mechanism wherein a set of Production servers will email me the results of system checks like Uptime, NFS Mounts and a Process after every scheduled reboot.
For this, I figured I'd use the @reboot parameter that crond comes with.
I have added the below onliner in crontab for root:
@reboot up=`/usr/bin/uptime| cut -d, -f1,2`; tck=`ls -l /path/to/mounted/file`; pst=`ps -ef | grep ManageProcess`; echo -e "Uptime: $up \n\nMount Check: $tck \n\nManageProcess Check:\n\n$pst"| mail -s "[DIFMON]`hostname` is UP After Reboot" pocodot@mydomain.com
No mail. If I run the above line on a shell, I get proper email with all the status.
I figured the ; after each command may be cutting the command run on crontab and tried as below:
@reboot up=`/usr/bin/uptime| cut -d, -f1,2`;
@reboot tck=`ls -l /path/to/mounted/file`;
@reboot pst=`ps -ef | grep ManageProcess`;
@reboot echo -e "Uptime: $up \n\nMount Check: $tck \n\nManageProcess Check:\n\n$pst"| mail -s "[DIFMON]`hostname` is UP After Reboot" pocodot@mydomain.com
I guess crontab is possibly not able to handle variable declaration.
I dont want to run a script from crontab since this is a production server and I wont be allowed to place my script anywhere in filesystem.
Could anyone help me with this please?
Bonus question: I notice that @reboot option runs even if the crond service is restarted whereas the documents say this will run only on boot/reboot. Is this not weird?