Deleting a script.

Issues related to software problems.
patryk20120
Posts: 5
Joined: 2014/08/05 19:18:36

Deleting a script.

Post by patryk20120 » 2014/08/05 19:24:14

Hello,

I am trying to create a script that will reboot system after bad shutdown(by pulling the plug out of the power). I created it using bash in /etc/init.d/.
I am not pro in this that's why I have one dilemma, if something goes wrong and system will keep rebooting, is there a way to turn off that script or delete it?

Best Regards and thanks in advance

User avatar
TrevorH
Forum Moderator
Posts: 26942
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Deleting a script.

Post by TrevorH » 2014/08/05 20:40:01

I don't understand what you are trying to achieve. As I read your post, you are attempting to write a script to reboot the system after it has rebooted following an unclean shutdown like a power off? That makes no sense. If it comes back up after the unclean shutdown then it's already ready to use and you don't need to shut it down again.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

patryk20120
Posts: 5
Joined: 2014/08/05 19:18:36

Re: Deleting a script.

Post by patryk20120 » 2014/08/06 09:15:15

OK. Different way.

I have script on startup with a commend "reboot". How to stop system from rebooting.
I know that I can run LiveCD and delete the script but I have problem with mounting hard drive and cant get to CentOS files.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Deleting a script.

Post by gerald_clark » 2014/08/06 12:51:00

You say it is in /etc/init.d.
How are you running it.
If it is a standard init script it must be tied to specific runlevels.
Can you boot to single user and then remove it?

Otherwise boot the install DVD in rescue mode and follow the onscreen instructions to mount your root filesystem.

User avatar
TrevorH
Forum Moderator
Posts: 26942
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Deleting a script.

Post by TrevorH » 2014/08/06 13:01:20

I still don't understand why you would ever write and install such a script - it's idiotic and the best thing to do is not do it.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

patryk20120
Posts: 5
Joined: 2014/08/05 19:18:36

Re: Deleting a script.

Post by patryk20120 » 2014/08/06 16:03:10

TrevorH what you don't understand? :P

Case looks like this:
I have pbx on CentOS, when there is no power phones are not working, I have to manually delete mysql.sock and reboot the system. I can not find the solution for this. Faster is to create a script that will deleting this file and reboot system, which I did. Script is in /etc/init.d/ and runs at all levels. The script is working fine.

BUT in case that something will happend and system will keep rebooting, how to delete this script?

I hope that everything is clear. Sorry for my english.

drk
Posts: 401
Joined: 2014/01/30 20:38:28

Re: Deleting a script.

Post by drk » 2014/08/06 16:20:30

patryk20120 wrote:I have to manually delete mysql.sock and reboot the system.
Why not just remove mysql.sock before you attempt to start mysql?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Deleting a script.

Post by gerald_clark » 2014/08/06 16:43:43

Edit /etc/rc.d/rc.local and add the line:

rm /var/lib/mysql/mysql.sock

patryk20120
Posts: 5
Joined: 2014/08/05 19:18:36

Re: Deleting a script.

Post by patryk20120 » 2014/08/06 17:06:16

drk wrote:
patryk20120 wrote:I have to manually delete mysql.sock and reboot the system.
Why not just remove mysql.sock before you attempt to start mysql?
No clue how to do this.
gerald_clark wrote:Edit /etc/rc.d/rc.local and add the line:

rm /var/lib/mysql/mysql.sock
I think that won't work, because I have to remove mysql.sock before mysql will start so it can create new one.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Deleting a script.

Post by gerald_clark » 2014/08/06 17:32:31

patryk20120 wrote:I think that won't work, because I have to remove mysql.sock before mysql will start so it can create new one.
You are right the change would have to be made to /etc/rc.d/rc.sysinit until /etc/init.d/mysql is fixed.

Post Reply

Return to “CentOS 5 - Software Support”