One of my server reboots every sunday and monday morning, whenever the server is up I need to do a service restart. Actually I call a script to execute itself (everytime manually). What I want to achieve is that it should be possible to invoke this script to get executed every time the server boots up. Is this possible?
The script I execute everytime is something like this:
cd /var/www/activefolder/current && RAILS_ENV=production script/delayed_job start
As you can see this script combines two tasks to finish this.
The server OS is Redhat EL 7. I guess until 6, OS uses init.d whereas RHEL7 introduces a more flexible option called systemd. But not sure whether it is possible to setup as I mentioned. Any help would be really appreciated.
Not sure whether I have given you all the requirements to answer this question. If not, please feel free to ask and I will update my question with the relevant information.
Best Answer
Based on Redhat's documentation Creating Custom Unit Files and systemd.exec — Execution environment configuration:
Not tested™
Create the file (touch>chmod>edit seems recommended, I don't known why):
/etc/systemd/system/activefolder.service
example:Then: