I'm writing a bash script which, among other things, will edit crontab on another server. The way I figured out how to do this is with:
crontab -l | sed <stuff> | crontab -
It does what I need it to do, but I'm still not sure how. What exactly does "crontab -" do? When I run it by itself from the shell, it takes over the shell until I hit ctl+c, but doesn't seem to do anything. Is its only purpose to overwrite cron contents with whatever's passed from stdin? I can't seem to find any documentation on it.
man
page forcrontab(1)
includes notice about the handling of system default warning comments when usingcrontab -l | crontab -
. – user4556274 Jan 15 '18 at 16:01crontab -l >.crontab; sed ... .crontab | crontab
, which would leave me a copy of the original in case mysed
command mangled the data irrecoverably. – Chris Davies Jan 16 '18 at 13:44