Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
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.

Start bash .sh script with parameters on boot?

FreekFreek Member
edited December 2012 in Help

I have a bash script (.sh) that I need to start on boot but it requires parameters. Manually one can start it by 'bash script.sh -start'

I tried crontab -e with @reboot bash /path/to/script.sh -start
but that didn't work.

So how exactly do you call/start a bash.sh script with parameters on boot?

This is on Ubuntu 12.04

Thanks :)

Comments

  • marcmmarcm Member
    edited December 2012

    Just call it from /etc/rc.local - it's crude, but elegantly simple IMHO :-)

    @BronzeByte - thanks :)

  • /etc/rc.local

  • keep the script at location /etc/init.d .. and then type .. update-rc.d scriptname defaults

    this way your script will run on every Boot automatically ... tested on debian 6

  • @marcm said: Just call it from /etc/rc.local - it's crude, but elegantly simple IMHO :-)

    :P It's exactly the same on FreeBSD (get's launched from the /etc/rc.d/local script).

  • Thanks, the /etc/rc.local trick worked :D

    @fresher_06 I'm not very handy with rewriting scripts that call other files in other locations. Might solveable with a simple symlink nonetheless?

    Anyway it works. Thanks for the fast responses guys!

  • put yout script to /etc/rc.local

    work on centos 5.8 and debian 6

  • @fresher_06 said: keep the script at location /etc/init.d .. and then type .. update-rc.d scriptname defaults

    this way your script will run on every Boot automatically ... tested on debian 6

    I think you actually have to use a proper init script with the proper headers and such on it, lest debian6 starts flipping warnings at you. (though guess it'd still work).

  • @kbeezie .. it actually worked .. as I have just created bash script .. with iptables commands .. ..save it into /etc/init.d location .. typed .. update-rc.d myscriptname defaults .. it does threw some warnings .. but it actally works .. might work on a normal script as well without keeping it in /etc/init.d .. just by update-rc.d scriptname defaults .. not checked the second condition though

Sign In or Register to comment.