Vimal Annamalai Vimal Annamalai - 15 days ago 10
Python Question

How to make the .sh file should be in running state always

I'm new to shell scripting, i want the command to be in running always.
My .sh file -

startscrapy.sh


#!/bin/bash
echo "Scrapyd is started now"
scrapyd


i have changed the permission also
chmod +x etc/init.d/startscrapy.sh


I have placed this file in etc/init.d but it is not working.
My understanding as of now " the location
etc/init.d
is to run the .sh files
whenever the server or system boots up but i want my .sh file to be running state always.

Answer

Using crontab you can easily auto start any scripts in ubuntu.
Please do the following steps,

  1. Run the command crontab -e so that you can edit the crontab.
  2. Now add the following line to the crontab editor @reboot sudo <script> in your case it should be @reboot sudo scrapyd.
  3. Now reboot your system, then you will find scrapyd running.

Hope it Helps.