I have looked for an answer everywhere I can think of and either I'm looking in the wrong places or no one is attempting to enter cron jobs from scrips.
I have two cron jobs (below) that I am wanting to check or setup and run from another main bash script. the main bash script does the cron job entry ( no manual entry ). here they are (adjusted the paths for easier viewing):
if ! crontab -l | grep "@reboot /home/john/this_script.sh > /home/john/this_script_log.txt 2>&1"; then
(crontab -l ; echo "@reboot /home/john/this_script.sh > /home/john/this_script_log.txt 2>&1") | crontab -
and
if ! crontab -l | grep "/home/john/that_script.sh > /home/john/that_script_log.txt 2>&1"; then
(crontab -l ; echo "* * * * * /home/john/that_script.sh > /home/john/that_script_log.txt 2>&1") | crontab -
fi
the permission are set and have been tested. so they both run.
I don't want to use crontab -e
to adjust or enter any of the above cron jobs (thus the pipe to crontab -
). as far as I know the above if statements check to see if the cron job is already there and if it is not, it enters it.
the challenge is I mistakenly entered the wrong path on one of them. after discovering the mistake, I attempted to edit it.
I used crontab -e
and couldn't find it.
crontab -l
and it doesn't show up.
does anyone know how to find and edit any of the above script entered (crontab -
) crontabs?
thank you