Crontab: Difference between revisions
Jump to navigation
Jump to search
Anthoanthop (talk | contribs) (Created page with "=Match pattern A OR Pattern B OR Pattern C ...= <syntaxhighlight lang="bash"> tcpdump -A host bob.net | egrep '\"site\":{\"id\":\"(386105|87347|166881|381105|316817)\"' </syn...") |
Anthoanthop (talk | contribs) No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Comment out a specific crontab job= | =Comment out a specific crontab job= | ||
Line 11: | Line 5: | ||
*/10 * * * * /usr/share/mapstats/mapstats | */10 * * * * /usr/share/mapstats/mapstats | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Locally: | * Locally: | ||
Line 16: | Line 11: | ||
crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab - | crontab -l | sed 's/.*\usr\/share\/mapstats\/mapstats/#&/' | crontab - | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Remotely on multiple servers, example: | * Remotely on multiple servers, example: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
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> | |||
=Uncomment the job from our previous example= | |||
<syntaxhighlight lang="bash"> | |||
crontab -l | sed '/.*\usr\/share\/mapstats\/mapstats/s/#//' | crontab - | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 11:18, 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 -