I created a .sh file and it is email.sh

In this email.sh file I have these lines

php /home/username/public_html/Worker.php

Now, I want to make that email.sh as a startup service in the server and this script always in the background of my Centos server.

Can you please help me how to do this?

  • "script always in the background of my Centos server" What does this mean? – Ruban Savvy Dec 23 '13 at 3:52

To run a script on startup, use the @reboot mechanism in cron. Add this line to /etc/crontab:

@reboot root /usr/local/bin/email.sh &

Make sure the script is in /usr/local/bin. It will run until stopped, so it can stay in the background.

  • When I run that code, I got @reboot: command not found – delphiman Dec 23 '13 at 22:06
  • 1
    you shall put it into /etc/crontab – Thorsten Staerk Dec 24 '13 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.