0

I have to automate my Crontab script and would like to insert some things in my Crontab file, I want to do that without interactive query and it should look like command:

crontab_admin.sh -add -s "15 9 * * *" -c "check_backup_include_list.sh" -u "USERNAME" -t "CRQ000000000000"

crontab_admin.sh -remove -s "15 9 * * *" -c "check_backup_include_list.sh" -u "USERNAME" -t "CRQ000000000000"

and it should look like this in crontab afterwards:

15 9 * * * $HOME/scripts/check_backup_include_list.sh

sry for my bad english

1 Answer 1

3

Its not wise to operate directly with cron file. But you can add record with script like this:

crontab -l >/tmp/c1
echo '15 9 * * * /full/path/to/scripts/check_backup_include_list.sh' >>/tmp/c1
crontab /tmp/c1

If you want to remove particular record you can do for example with something like this:

crontab -l >/tmp/c1
grep -v check_backup_include_list.sh' /tmp/c1 > /tmp/c2
crontab /tmp/c2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.