weihk
asked on
how to use if/then statements in crontab?
Hello,
I'm new to unix shell programming. I was wondering if there is a way to use if/then statements in crontab? If so, can you please give me an example, or the problem I'm working on is reading a file for a specific line (ex: hello there) and if it is read more than 2 times then execute a reboot of that particular server.
The code below is what I have so far but not sure how to fully utilize the if/then statement. Thanks for your help.
I'm new to unix shell programming. I was wondering if there is a way to use if/then statements in crontab? If so, can you please give me an example, or the problem I'm working on is reading a file for a specific line (ex: hello there) and if it is read more than 2 times then execute a reboot of that particular server.
The code below is what I have so far but not sure how to fully utilize the if/then statement. Thanks for your help.
*/5 * * * * awk '{if($15 ~/XFMRDPAD/) shutdown -i6}' StructureService_PR.log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i found out that i'm suppose to stop the IS (integration server) using this command:
call vtadmin stop server /StructureService_PR/initi al/Structu reService_ IS
and reboot the project using this command:
call vtadmin start project /Projects/StructureService _PR/initia l
can i just replace the "shutdown -i6" with those commands? or how will i be able to implement it into the code? thank you
call vtadmin stop server /StructureService_PR/initi
and reboot the project using this command:
call vtadmin start project /Projects/StructureService
can i just replace the "shutdown -i6" with those commands? or how will i be able to implement it into the code? thank you
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Specifying full path to commands helps in crontab.
No "if" statements in your command line, just gawk syntax.