New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Adding a script to startup on a VPS
GarrettRocky
Member
What's a good way to add a script to startup so that it runs as if you had typed the commands yourself over SSH? i know vultr and linode have a startup script section, but some other providers like digitalocean dont have that.
i launch a ton of servers and its getting super annoying having to login to each one and type them myself.
thanks for the look and help guys!
Edit: i am using debian
Comments
/etc/rc.local
?Use a cronjob that runs at boot/reboot or use /etc/rc.local.
A cronjob at reboot would be like
rc.local has to be edited with a text editor simply and then you add "/path/to/your/script" at the bottom of the content but before "exit 0".
anyone havea good video or tut on how to do this? sorry im just super new to all of this and have no idea, thanks for the help
crontab -e
Enter your cronjob as suggested by Respected @Cartman and save it.
@GarrettRocky - First try my method and If you failed then I will make video tutorial for you.
@DewlanceVPS i tried and i failed miserably lol, if you could make a tut it would be greatly appreciated, thanks again.
On AmigaDOS, use S:Startup-Sequence
If you lack knowledge so much on putting a simple command in cron, I really wonder what kind of script you want to add to your server...
Anyway, with crontab -e you open the crontab script in an editor. If it opens with vim, you maybe want to change to an easier editor, like nano.
Do an update
sudo apt-get -y update
, install nanosudo apt-get install nano
and open crontab with nanoEDITOR=nano crontab -e
Then, add what @Cartman said to your crons:
You can add it by copying it and press left button to your mouse, when using putty as a terminal. Then, press ctrl+x to save and exit. Don't forget to make your script executable
chmod +x /path/to/your/script
No, Problem. I can make a video tutorial for you but I want to know that you are using CentOS or Ubuntu?
@DewlanceVPS Debian
Sounds more like a configuration management question. Learn to use something like Chef, Puppet, Ansible, etc. Or hire someone to manage your servers for you if you're in over your head.
If you are completely new to Linux, I would recommend that you learn to use vi/vim before doing anything. After that you'll be able to edit /etc/rc.local and add start-up scripts.
@GarrettRocky - go to youtube and search for debian startup scripts
You could install Webmin or similar. From there you can do an awful lot of your necessary housekeeping
Don't get discouraged by the time it's taking you to learn how to manage a vps, i joined this forum in November of 2013 at that time I was totally green,
Believe me if you roll up your sleeves take your time and read everything you can find,
get a small server to practice on after awhile you will soon realize that most of this stuff is ridiculously easy that is why some of the old-timers here turn nose up at people when they say they're going to use a VPS control panel but there are a lot of good vps control panels, I use vastacp for example saves a lot of time, but I am fully capable I'm doing everything by command line..
you have to practice you have to work on different projects even if you don't need to..
nano, thanks.