LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2011, 07:12 AM   #1
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Rep: Reputation: 1
script


Hi

i have centos5.3 i have to run 3 command when my server boot
adsl-start
adsl-stop
service squid restart
i want to create a script which will fire this command

can anyone guide for same


AMar
 
Old 10-19-2011, 07:19 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Just add the commands to the end of /etc/rc.local
 
Old 10-19-2011, 07:22 AM   #3
miguel.axcar
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Rep: Reputation: Disabled
Mate, did you try to use /etc/rc.local file?
That's the file you insert your scripts to run at boot.

And don't forget to make sure that the script will "exit 0" on success.

Cheers,

Luiz Miguel Axcar
miguel@axcar.com.br
Bauru, São Paulo, Brasil
 
Old 10-19-2011, 07:33 AM   #4
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Thanks for reply

Actually i want to run this command after boot, sorry i mention earlier wrong that required at boot time , i want a script on which i click and run after boot manually


AMAr
 
0 members found this post helpful.
Old 10-19-2011, 08:21 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
So then throw commands in a file and make it executable and run it from the terminal once your in?
 
Old 10-19-2011, 08:27 AM   #6
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Hi

Can you pls guide how to do it
 
0 members found this post helpful.
Old 10-19-2011, 08:53 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
Just open your favourite editor and place the commands in it. You then have a choice you can either run it using your shell interpreter or place that at the head of the file like
so (assuming bash):
Code:
#!/bin/bash
Then save it and make it executable using chmod (look in man chmod if not sure) and then if you do the above you can run it at the command line like so:
Code:
./your_script.sh
 
Old 10-19-2011, 09:33 AM   #8
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
hi

i make test.sh file i add as follows
#!bin/bash
adsl-stop
adsl-start
service squid start
and make chmod -R 777 test.sh

but when i run this ./test.sh

shows bin/bash bad interpretor no such file and directory
 
0 members found this post helpful.
Old 10-19-2011, 11:00 AM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
Because you missed the leading slash:
Code:
#!/bin/bash
 
1 members found this post helpful.
Old 10-20-2011, 04:59 AM   #10
amartlk
Member
 
Registered: Sep 2010
Location: Nagpur India
Posts: 347

Original Poster
Rep: Reputation: 1
Thanks solved

AMAr
 
0 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash and xterm: how make apps started by and for a script persist when script terminates porphyry5 Linux - General 4 06-15-2011 02:27 PM
[SOLVED] Script question: create a shell script in kde to log in on a server with ssh c4719929 Linux - Newbie 1 01-31-2011 04:05 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 09:40 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 10:10 PM


All times are GMT -5. The time now is 01:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration