Crontab: Difference between revisions

From Anthony Pastor Wiki Notes - Verba volant, scripta manent
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
for i in 172.16.16.{1..50}; do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $i "crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab -" ; done
for i in 172.16.16.{1..50}; do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $i "crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab -" ; done
</syntaxhighlight>
</syntaxhighlight>


=Uncomment the job from our previous example=
=Uncomment the job from our previous example=

Revision as of 11:17, 11 May 2016

Comment out a specific crontab job

Let's say we have many jobs in crontab and we'd like to comment out this one:

*/10 * * * * /usr/share/mapstats/mapstats
  • Locally:
 crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab -
  • Remotely on multiple servers, example:
for i in 172.16.16.{1..50}; do ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $i "crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab -" ; done


Uncomment the job from our previous example

crontab -l | sed '/.*\usr\/share\/mapstats\/mapstats/s/#//' | crontab -