Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a simple upstart job: - /etc/init/hmastart.conf

I want to test it, so i run:-

service hmastart start

But i receive the following error:-

start: Unknown job: hmastart

I get the same error message if i try:

start hmastart

I have also tried adding sudo to the beginning, but i get the same error.

Here is my script

description "Starts HMA VPN"
author "Me <myself@i.com>"

start on runlevel [2345]

stop on runlevel [016]

respawn

expect fork

exec sudo /usr/local/bin/hma-vpn -p tcp London

My conf file has the same permissions as all the other conf files in /etc/init.

Could someone please tell me why this script cannot be found/run?

Many thanks in advance!!`

share|improve this question
    
I just put your script in /etc/init/hmstart.conf on my system, changed the command in exec to something harmless, and ran it with sudo service hmastart start. It started right up. I'd double-check all the permissions and locations. Also please indicate your Ubuntu version (I tested on 13.04). –  roadmr Aug 16 '13 at 13:12
    
Thanks roadmr, you kind of helped me answer this. My script actually contained lots of comments, like the ones in this example. By removing them, like i did when i posted my script here, it ran like a charm. Thanks very much. –  user184604 Aug 17 '13 at 9:32

2 Answers 2

Your script should look like:

# description "Starts HMA VPN"
# author "Me <myself@i.com>"

start on runlevel [2345]

stop on runlevel [016]

respawn

expect fork

exec sudo /usr/local/bin/hma-vpn -p tcp London

To start it, use:

sudo service hmastart start
share|improve this answer
    
Thanks Radu, but description and author are valid without being commented out –  user184604 Aug 17 '13 at 9:22
    
Well, for me it works like I said –  Radu Rădeanu Aug 17 '13 at 11:06

If your user doesn't have the NOPASSWD option configured for sudo then that could be why it's not starting as expected. To configure your account for sudo access without a password, edit the sudoers file:

sudo visudo

Append to the file:

username ALL=(ALL) NOPASSWD: ALL

Where username is your username in your system. Save and close the file.

WARNING: this decreases security by allowing your account to run any command as root without requiring a password!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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