LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-02-2008, 09:03 AM   #1
dipuasks
Member
 
Registered: Oct 2005
Location: India
Distribution: Redhat 7-9,Fedora Core 3 - 9, RHEL 4 -5, CentOS 4 - 5, Ubuntu 7.10 - 12.10, Mandirva 2008 -2009
Posts: 133

Rep: Reputation: 16
Cool Find and Replace


Hi,

I want change the memory limit in the php.ini file for around 100 servers and I have got couple of questions.

1. What is the command will find the parameter memory_limit=XX and change it to memory_limit=128M ?

2. I want to make this change on around 100 remote servers for which I have root password. Any ideas how to do it through a script?

--Dipu
---------------------
Windows? reboot. Linux! be root!!

http://www.smartdipu.info
 
Old 07-02-2008, 09:15 AM   #2
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 44
for the 2nd question you can read through this thread. I was looking for a similar solution to a problem

http://www.linuxquestions.org/questi...ervers-640817/



You'll need to set up SSH keys.

http://www.linuxquestions.org/linux/...ation_with_ssh
 
Old 07-02-2008, 11:45 AM   #3
dipuasks
Member
 
Registered: Oct 2005
Location: India
Distribution: Redhat 7-9,Fedora Core 3 - 9, RHEL 4 -5, CentOS 4 - 5, Ubuntu 7.10 - 12.10, Mandirva 2008 -2009
Posts: 133

Original Poster
Rep: Reputation: 16
mmm..........i looked into the links, but I don't have scripting knowledge at all so I can't make it myself. Anyways, please answer the 1st question and then we will discuss the 2nd.

Thanks for the reply

--Dipu
---------------------------
Windows? reboot. Linux! be root!!

http://www.smartdipu.info
 
Old 07-02-2008, 01:44 PM   #4
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
Test this for starters:
sed -i 's/memory_limit=.[0-9]M/memory_limit=128M/g' /path/to/php.ini

Would have been easier if you only have "memory_limit=nnnM" and no other characters/numbers after it on that line.
 
Old 07-02-2008, 01:52 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
sed -i.bak -r 's/(memory_limit[ \t]*=[ \t]*)[^\t ;]+(.*)/\1128M\2/' php.ini
Once the authentication to those machines is enabled (will be a tad
tedious) you can do something like:
Code:
for i in `cat hostlist`; do ssh user@${i} "sed -i.bak -r 's/(memory_limit[ \t]*=[ \t]*)[^\t ;]+(.*)/\1128M\2/' /etc/apache/php.ini"; done


Cheers,
Tink
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace upwordz Linux - Newbie 7 05-10-2007 09:03 PM
find and replace script UnixKiwi Programming 12 04-16-2007 11:08 PM
find and replace happy78 Programming 11 09-10-2005 10:21 AM
Help - how to find and replace in Vim stardotstar Linux - Software 7 10-14-2004 11:31 PM
Find and Replace? duerra Linux - General 9 01-28-2004 04:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:17 AM.

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
Open Source Consulting | Domain Registration