Skip to main content
deleted 43 characters in body
Source Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441

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.

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.

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.

adding something I forgot
Source Link
k.Cyborg
  • 527
  • 3
  • 10
  • 22

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.

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.

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.

Source Link
k.Cyborg
  • 527
  • 3
  • 10
  • 22

Why crontab doesn't execute a scheduled bash script?

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.