below mentioned script has my crontab running functions.
# Chef Name: binary_log_purge 0 */4 * * * /engineyard/bin/binary_log_purge -q
# Chef Name: database_oom_score
*/30 * * * * /engineyard/bin/database_oom_adj
# Chef Name: logrotate -f /etc/logrotate.d/stats 0 * * * * logrotate -f /etc/logrotate.d/stats
# Chef Name: cpu_utilaisation
*/5 * * * * cd /tmp && sh cpu_util.sh >> cpu_utilaisation.log
# Chef Name: Test_script
*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log
The above mentioned query i want to remove the blow line
# Chef Name: Test_script
*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log
How can i remove the function with below mentioned steps:
Step 1 : first i want to find the below line is there or not. How can i find out?
*/2 * * * * cd /tmp && sh test.sh >> tests_cript.log
Step 2 : If the line is there. I want to remove the function. How can i remove the function ?
Please help me.....
According to man 5 crontab the crontab files are not intended to be edited directly.
What you can do is run crontab -l, filter out the line using grep -v,
run crontab -r to clear the crontab then pipe the modified version of the crontab file into crontab -.
You can use grep -A 1 'Chef Name: Test_script' | grep -v "^#" to get the line after Test_script but ignoring commented out lines.