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 06-25-2013, 09:36 PM   #1
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Rep: Reputation: Disabled
Smile How to start rsync on shutdown ?


Hi guys, i hope someone can share me about this.
i write a script to rsync when shutdown is it possible to set the rsync untill 7am then the server shutdown or something like that ?
 
Old 06-25-2013, 09:48 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,346
Blog Entries: 12

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
Maybe this thread will help:

http://www.linuxquestions.org/questi...utdown-565029/
 
Old 06-25-2013, 09:49 PM   #3
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
hey thanks.. let me have a look on it..
 
Old 06-25-2013, 09:50 PM   #4
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
owh... i do read that.. thanks.. but is there anyway to set the limit time to rsync then it shutdown??
 
Old 06-26-2013, 12:12 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
So what's the problem with the suggestions in that thread?

Unless you want this to ALWAYS happen (& I doubt it), easiest is to write a script that calls rsync, then calls shutdown and call that script instead of calling shutdown.
This doesn't mess with the std shutdown, should you need it (& you will).
To specify a start time, use the 'at' cmd http://linux.die.net/man/1/at
 
Old 06-26-2013, 04:42 AM   #6
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
well i want the rsync to act like this.. run the rsync when shutdown the server (will put the rsync script in rc.shutdown) then when the rsync running, i want it to run only 2 hour or maybe 3 hour after that the computer goes shutdown.. any ideas guys??
 
Old 06-26-2013, 05:40 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
You're planning to kill rsync after X hrs, even if its not finished???
 
Old 06-26-2013, 10:24 AM   #8
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
yeah what is the point of running rsycn if you are only going to terminate it before it completes its task?
 
Old 06-26-2013, 10:35 AM   #9
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,797
Blog Entries: 1

Rep: Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341Reputation: 1341
You can use this function:
Code:
runfor() {
runtime=${1:-1m}
mypid=$$
shift
$@ &
acpid=$!
sleep $runtime
kill -s SIGTERM $acpid ;}
So,.. using this command would run rsync for 3600*3 seconds or 3 hours and kill it.

Code:
runfor 10800 rsync -varh /thisstuff somewhere:/to/here/
You can test it by copying/pasting that function into a command prompt and running:

Code:
runfor 10 ping 4.2.2.2

Last edited by szboardstretcher; 06-26-2013 at 10:37 AM.
 
Old 06-28-2013, 03:21 AM   #10
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
ok thanks... let try it...
 
Old 06-28-2013, 03:25 AM   #11
diskless.solve
LQ Newbie
 
Registered: Feb 2013
Posts: 11

Original Poster
Rep: Reputation: Disabled
i forgot to tell you guys... im running on slackware 13.1.. can this script run on slackware ??
 
  


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
how to start mysql after shutdown?? loplayers Linux - Newbie 1 10-26-2007 12:12 AM
how to rsync at shutdown ikinnu Linux - Software 3 06-28-2007 09:14 AM
remote start and shutdown upload-3 Linux - Networking 3 12-24-2004 06:20 AM
Start-Up/Shutdown Script ptreves Linux - Newbie 1 09-15-2004 05:27 PM
Cannot shutdown computer or kill -9 hung rsync JLindenmuth Linux - General 0 05-05-2004 02:23 PM


All times are GMT -5. The time now is 03:57 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