ubuntu server, trying to get a service/daemon to start

9,821

Solution 1

I typed sudo crontab -e and then selected nano as my editor. It brought up nano with the below comments. I added my script at the bottom and then rebooted. My tasks are now running whenever the system is booted.

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
@reboot /path/to/script.sh

Solution 2

It is possible to get that error if the script is not executable

sudo chmod +x /etc/init.d/mydaemon

Solution 3

Have you located and tried running the service the service in /etc/init.d/(service name)?

I am unfamiliar with invoking services without actually running the shell program located under init.d folder but I am sure if the shell program to start the service is located under init.d then it should be an easy setup so you can invoke it the way you wish - "service mydaemon [command]"

Share:
9,821

Related videos on Youtube

Saumy tiwari
Author by

Saumy tiwari

Updated on September 18, 2022

Comments

  • Saumy tiwari
    Saumy tiwari over 1 year

    I followed the instructions here, but when I enter "sudo service mydaemon start". I get "mydaemon: unrecognized service". I have verified that the files are in the proper places, and I took the additional step of making my script file (echoHW.sh) executable, still no success. Any help whatsoever would be greatly appreciated.

  • Saumy tiwari
    Saumy tiwari about 12 years
    MAN I wish that had worked, but it didn't. Is there someplace I can look at a log file that might tell me what went wrong.
  • Saumy tiwari
    Saumy tiwari about 12 years
    If you mean "sudo service /etc/init.d/mydaemon start", I just tried that (when sitting in /etc/init.d/), and got "/etc/init.d/mydaemon: unrecognized service".
  • Stephen R
    Stephen R about 12 years
    In that case I would be concerned about the service properly installing on the machine, or that the shell command to start the program simply doesn't exist in the init.d folder for whatever reason. I am not a Linux pro by any means so I am unsure of how to assist from here. Is it a package you downloaded? Or is it a daemon/service you wrote?
  • Saumy tiwari
    Saumy tiwari about 12 years
    Actually, I checked the cron log, and it DID run. So now I've got to take a look at my scripts. Thanks!
  • Saumy tiwari
    Saumy tiwari about 12 years
    It was just the files as described in the page I referenced.
  • Saumy tiwari
    Saumy tiwari about 12 years
    It's all local at this point, ports aren't the issue.