I need to create a bash script in order to:
- Empty my root Crontab;
- Insert new Cronjobs via bash script.
For the first point I can use crontab -r
For the second point instead here I found this script:
#!/bin/bash
lines="* * * * * /path/to/command"
(crontab -u root -l; echo "$lines" ) | crontab -u root -
How can I cook this together in a bash script?
Something like this:
#!/bin/bash
crontab -r
line="* * * * * /path/to/command;
* * * * * /path/to/command2;
* * * * * /path/to/command3"
(crontab -u root -l; echo "$line" ) | crontab -u root -