LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-08-2020, 06:53 PM   #16
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by sgosnell View Post
IMO, 'a' is a better choice than 'r', because it includes 'r' but does more. Most people would, I believe, use -a as a matter of course for a backup, unless they had a special situation. For an explanation of -rlptgoD, run rsync --help in a terminal. Or read the manual by running "man rsync" in a terminal.
With -v, you could pipe the output to a log file, which you could read at your leisure and see if things were actually being done the way you want. With no pipe, it just goes to standard out, and does no harm. The -z option compresses the data (only during transmission, not on file write) for faster and more efficient operation. It's your choice, though, and just -r alone will work.
Comming from 30+ years of GUI, I tend to read the manuals online. Terminal mode is not my preffered option.
Anyway, when I used the -a initially, it did something wrong - it was copying into itself also the alexfolders folder... all over again. I find that -r is working OK.

Now, I feel that I am missing something, here are the steps I did:

Created the scrip file call anajob and placed it inside the /tc folder
Ran the command inside that folder : sudo chmod 755 anajob
It executed and got back to the prompt.

Now, I am unclear as to what should I do with this:
Code:
1 10 my-backups /path/to/my_backup_script
the path to my backup scrip is now /etc/anajob

Do I need to create a cron job for this?

Please explain

Thanks again
Alex
 
Old 09-08-2020, 06:55 PM   #17
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Quote:
seeder1@haswell:~$ man rsync
.... snip

--log-file=FILE log what we're doing to the specified FILE

Is probably the best for doing a log. My favourite options for the command.


MacUser2525:~$ alias rs
alias rs='rsync -avP'
There are many ways to do it, and rsync provides many more choices. That's why it's important to read the man pages and see what you want/need, and what you don't. There is a learning curve, but it's worth riding that curve.

Last edited by sgosnell; 09-08-2020 at 06:57 PM.
 
Old 09-08-2020, 07:06 PM   #18
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Using -a instead of -r was not the cause of copying to the wrong place. Neither changes the destination at all.

If you want to read the man pages online, that's perfectly fine. All the man pages for almost every package are available.
https://www.man7.org/linux/man-pages/
https://www.linux.org/docs/index.html
Reading may make posting questions unnecessary, and will certainly enable posting more directed questions.
 
Old 09-08-2020, 07:09 PM   #19
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Code:
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1	 5	cron.daily		nice run-parts /etc/cron.daily
7	 25	cron.weekly		nice run-parts /etc/cron.weekly
@monthly 45	cron.monthly		nice run-parts /etc/cron.monthly
1        10     my-backups              /path/to/my_backup_script
An as an example this is the default anacrontab from CentOS 7. You would add your line after the last line in that file as illustrated above.
 
Old 09-08-2020, 07:33 PM   #20
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Code:
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1	 5	cron.daily		nice run-parts /etc/cron.daily
7	 25	cron.weekly		nice run-parts /etc/cron.weekly
@monthly 45	cron.monthly		nice run-parts /etc/cron.monthly
1        10     my-backups              /path/to/my_backup_script
An as an example this is the default anacrontab from CentOS 7. You would add your line after the last line in that file as illustrated above.
OK, my anacrontab file looks now like this:

Code:
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1 10 my-backups /etc/anajob
Will this do the job?

Thanks again
Alex
 
Old 09-08-2020, 08:12 PM   #21
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Make sure that anajob is executable.

It will run everyday 10 minutes after the computer starts. Not to add to the confusion but when the job runs if the computer is already on depends on how anacron which is usually by cron. If no start_hours_range is defined it could be anytime.
 
Old 09-08-2020, 08:23 PM   #22
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Make sure that anajob is executable.

It will run everyday 10 minutes after the computer starts. Not to add to the confusion but when the job runs if the computer is already on depends on how anacron which is usually by cron. If no start_hours_range is defined it could be anytime.
Sorry, not clear - I thought it will run within 10 minutes from when I turn it on, once per day!
I have the machine on for 10-11 hours each day.

Are you telling me that it will run during that entire time every 10 minutes? I sure hope that's not the case.
I don't really care when during the day it runs, as long as it is sometime during those 11 hours.

BTW, it executed OK today shortly afte I modified the anacrontab file

Thanks
Alex
 
Old 09-08-2020, 08:33 PM   #23
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Quote:
It will run everyday 10 minutes after the computer starts.
I thought I did...
 
Old 09-08-2020, 08:38 PM   #24
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
I thought I did...
OK, I am relaxed now.
I also noticed that using the -r flag, is showing the file time stamps of the time the backup was executed, which is NOT a good idea. I am going to replace it with -a, to preserve the file time stamp, as suggest at first by sgonsell

Cheers
Alex
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning cron : CentOS7 : anacron and cron fanoflq Linux - Newbie 2 11-24-2016 09:50 PM
LXer: What is Anacron and usage of Anacron in Linux LXer Syndicated Linux News 0 01-14-2015 06:30 AM
LXer: What is Anacron and usage of Anacron in Linux LXer Syndicated Linux News 0 01-14-2015 02:00 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron / anacron / fcron Will Linux - General 3 11-09-2001 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:29 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
Open Source Consulting | Domain Registration