Cannot seem to get a cron job to run

nadinio

Dabbler
Joined
Jul 9, 2017
Messages
22
Hey all,

I currently have a strange issue when it comes to running a cron task that executes a basic script that restarts a few services within a couple of jails.

This is the command for the script:

/mnt/Production/Homes/alpha/restart-deluge.sh

And the script itself:

Code:
#!/bin/sh

jexec ioc-deluge /usr/sbin/service openvpn restart
sleep 10
jexec ioc-deluge /usr/sbin/service deluged restart
sleep 10
jexec ioc-deluge_web /usr/sbin/service deluge_web restart


I don't think I am missing anything here but whenever the cron job executes it just hangs indefinitely until I run the script manually. When I run the script manually everything executes just fine. I'm running the script as the root user. Any ideas why this is having such a weird issue?
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
I have a simple script that I run in a jail and I use the sh command to get it to run. Try changing your cron command to

sh /mnt/Production/Homes/alpha/restart-deluge.sh

and see if that works.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
To run the job without pre-pending sh, make sure the script has the executable bits set: chmod +x /mnt/Production/Homes/alpha/restart-deluge.sh.
 

nadinio

Dabbler
Joined
Jul 9, 2017
Messages
22
The permissions look okay on the script. I went ahead and tried the cron job with sh and have the same issue. It isn't a permissions issue. The cronjob just hangs until I run the script from command line.

1599973393470.png
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Then it's likely a PATH issue. Where do jexec and ioc-delugeexist? For cron jobs, it's always best practice to use the full path to executables.
 

nadinio

Dabbler
Joined
Jul 9, 2017
Messages
22
Hmm, I went ahead and updated the script to include the full path for jexec. Looks like I still have the same issue. ioc-deluge is the jail name so I don't think there is a full path for that.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Have you tried running the cron job inside the ioc-deluge jail, instead of outside the jail? Inside the jail, of course, there's no need to invoke jexec; just run /usr/sbin/service x restart.
 
Top