Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi all I am brand new to all of this so please bear with me. I have created this bash file as follows:

rm /home/ubuntu/test.jar
java -jar test.jar

Now I have placed that file in many various places, run some update thing, and also even made a cron job with the @reboot function.

No matter what, the java program is never actually started.

Now, this is an Amazon Web Services headless Ubuntu server with no GUI, only SSH access so I've gotta do it via command line, and have it run as a daemon of some sort. I appreciate any help!

share|improve this question
Do you want to run this as root, or do you want to run this as your user ("ubuntu")? Please also provide exact details about the cron job you have created--that is, please edit your question to include the output of crontab -l or cat /etc/crontab (whichever is relevant). Please give as many details as possible about exactly what you mean when you say you ran "some update thing." – Eliah Kagan Jun 1 '12 at 18:26
From your question right now, a few possibilities come to mind. Perhaps your cron line has the wrong syntax, or you're trying to run a script as an executable file that is not executable or lacks hashbang syntax, or the wget command is not executing in the same directory that test.jar is being downloaded to. (It's strange that you rm with the full path, but wget to the current directory to replace the file.) – Eliah Kagan Jun 1 '12 at 18:28
up vote 2 down vote accepted

Putting those lines to /etc/rc.local will be another option. (In newer versions of Ubuntu, /etc/rc.local does not exist by default, so you must create it. It is still used on boot, if it does exist.)

You should also try giving full path to executables not located directly in /bin, i.e., java and wget.

However, if you're trying to run this as a limited user (ubuntu?) rather than root, then using /etc/rc.local might not be the best way to do it, since commands in /etc/rc.local are run as root.

You can get /etc/rc.local to run a script as a non-root user, though (assuming you have administrative access and thus can create/edit /etc/rc.local). If the script you want to run is /home/ubuntu/runtest, you want to run it as the user ubuntu, and you are insistent on running it with bash, then you can add this line to the end of /etc/rc.local:

/usr/bin/sudo -u ubuntu bash /home/ubuntu/runtest > /dev/null
share|improve this answer
Thanks for adding up those comments. I didn't know Ubuntu 12.04 doesn't have /etc/rc.local anymore. – Samik Jun 1 '12 at 18:52

Your Answer


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.