I have seen a lot of times (1, 2 )this question, but I didn't find the answer, so here I go.
I'm running Debian 11, but I guess it works the same for any Debian-like distro.
My crontab -e looks like:
...
@reboot sleep 20 && /opt/isPromscaleOnOrOff.sh
...
And the content of isPromscaleOnOrOff.sh:
#!/bin/bash
SERVICE="promscale"
if pgrep -x "$SERVICE" >/dev/null
then
echo "$SERVICE is running"
else
echo "$SERVICE is stopped, I will run it now"
nohup promscale --db-name asdf1234--db-password asdf1234 --db-user asdf1234 --db-ssl-mode allow --install-extensions & >> /dev/null
disown
fi
But when I restart the VM the script isn't runing, tho the cron logs in /var/log/syslog show the crontab starting the script.
What I wanna achieve can be easilly done daemonizing the process (wich I indeed did), I just wanna know why crontab doesn't start up my script.
useras the login id for the user that owns this job. What recent errors are in the mailbox file/var/mail/user? (If it exists it will be readable as a plain text file.)cronattempted to start it, because you haven't recorded that the script ran.