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.

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
wget http://mywebsite.com/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
add comment

1 Answer 1

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
add comment

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.