Just want to write a ruby script that reboots the computer for 10
repeated times. Is it possible? I appriciate any help.
在 2010-02-06å…çš„ 17:52 +0900,Ham B.写é“:
Just want to write a ruby script that reboots the computer for 10
repeated times. Is it possible? I appriciate any help.
You may want to write a status file for the rebooting count.
For example:
rcdFile="/tmp/reboot.rcd"
times = 0
if File.file? rcdFile
File.open(rcdFile) do |f|
times = f.read.to_i
end
else
File.open(rcdFile,“w”) do |f|
f.write(times)
end
end
times += 1
File.open(rcdFile,“w”) do |f|
f.write(times)
end
if times <= 10
system(“reboot”)
end
Then run this script from crontab or system init scripts.
HTH.
Ham B. [email protected] wrote:
Just want to write a ruby script that reboots the computer for 10
repeated times. Is it possible? I appriciate any help.
Ensure that your system is configured in such a manner that members of
“shutdown” can reboot the system. Create a startup script to run the
rebooter
as a member of the shutdown group. From within the ruby software: create
a
counter" file if one does not exist, setting the count to 10. Use the
count
that the file contains. If the count is zero, then exit because the
system has
already rebooted 10 times, otherwise decrement the count and “shell out”
to
the reboot command.
Mark.
On 6 Feb 2010, at 11:10, Mark H. wrote:
the reboot command.
Remembering of course to explicitly flush the file buffer of the status
file and sync the filesystem before performing the reboot
Ellie
Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
raise ArgumentError unless @reality.responds_to? :reason
Eleanor McHugh wrote:
Remembering of course to explicitly flush the file buffer of the status file and sync the filesystem before performing the reboot
I’m astonished that the system reboot command does not do this!
Closing the file is certainly necessary. Isn’t the rest unnecessary?
Curious
Ian
On 6 Feb 2010, at 21:55, Ian H. wrote:
Eleanor McHugh wrote:
Remembering of course to explicitly flush the file buffer of the status file and sync the filesystem before performing the reboot
I’m astonished that the system reboot command does not do this!
Closing the file is certainly necessary. Isn’t the rest unnecessary?
Curious
If journalling’s enabled on the filesystem it’s probably unnecessary,
but let’s just say I’ve been stung enough times to be naturally
cautious…
Ellie
Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
raise ArgumentError unless @reality.responds_to? :reason
On Saturday 06 February 2010 04:32:54 pm Eleanor McHugh wrote:
If journalling’s enabled on the filesystem it’s probably unnecessary, but
let’s just say I’ve been stung enough times to be naturally cautious…
I guess it depends on the system you’re on – when I type ‘reboot’, my
system
shuts down, including killing all processes (giving them time to flush
their
buffers), then flushing the filesystem (twice) before actually
rebooting.
Now, if you did something like ‘reboot -f’, it would instantly reboot,
and a
journaling filesystem wouldn’t save you. Sure, your filesystem would be
fine,
but your data might not, especially if you only had half of it written,
with
the other half in a buffer somewhere.
Jeff P. [email protected] writes:
You may want to write a status file for the rebooting count.
For example:rcdFile=“/tmp/reboot.rcd”
If you put the staus file in /tmp, make sure your system doesn’t clear
that directory on each boot Some do.
-dan
Hi,
Step 1 → Create 1 text file like
sample.txt
Content:
10
Step 2 → Ruby program read the content from File. So its 10 now.
Before going to restart the machine write the file content as : 9 and
save the file.
Step 2 help → How to reboot machine ?
Step 3 → Before run the program PUT the rb file into SETUP
environment.
I think it will works. Please update once after tried in this way.
Thanks
Raveendran
ryt! yrt! rty! ytr! try!
Hi,
I have missed to mention step 5 in previous conversation.
Step 5 → When the file contains content == 1 then read and delete the
file. So next time it wont read the file and also wont run.
Sorry for the inconvenience.
Thanks
Raveendran
ryt! yrt! rty! ytr! try!