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-16-2020, 05:24 PM   #16
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by scasey View Post
It's not about being a newbie, it's about you making some effort to understand what you're being told.
We shouldn't have to spoon feed you.
command means your rsync command
>file1 means the file to capture the stdout
2>file2 means the file to capture the stderr

I don't see how that could be put any clearer, unless we simply type your commands for you. You'll learn better if you figure it out yourself.

Remember that the /full/path/to/file1 (the "absolute path") needs to be specified because you're working on a cron job.

We are of a similar age. Yes, I have been programming computers for a very long time (> 40 years), but I've always avoided calling myself an "expert," even when I was the resident expert.

The way to learn how to use Linux (or anything) is to learn how to look up how.
On Linux, that's the man pages, which are available online if you aren't comfortable reading them in a terminal. Simply put man command into your favorite search engine and you'll get several links to online copies of the documentation.

You need to answer the specific questions you've been asked. Show us the ls -l of the source and destination files that you think should be the same but aren't.

You should be getting a summary, either in the log files you're creating or in the emails being sent to root.
Dear helper,

Our current age is not really important, what is however is at the time of being that age, how long ago you started with it, compared to how long ago I did. It will not be possible for you to recal your situation at the start, nor how much spoon feeding you needed.

I read manuals, recently between 4-6 hours a day. The amount of information presented is an up-heel journey for me, so if I don't manage to absorb the pile of new things and I keep asking stupid questions, should IMO be forgiven.

The terms used here frquently, are cleared to the writer, not to a newbie.

What is the command "touch" doing, what is "stdout" doing? I can continue with the list but you get my point. Every response I received here, required that I go and Google the terms and even then, in many cases I have probably got it wrong.

Thanks again
Alex
 
Old 09-16-2020, 05:48 PM   #17
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Fair enough.
The touch command will create a file if it doesn’t exist or update the timestamp of one if it does.
We’re suggesting it to cause the destination device to “spin up” so it’s available to the rsync command.

The sleep command is to give it time to get to speed before the rsync command starts.

The -s option should be outputting a summary. The redirection should put that in the specified files.
 
Old 09-16-2020, 06:49 PM   #18
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Fair enough.
The touch command will create a file if it doesn’t exist or update the timestamp of one if it does.
We’re suggesting it to cause the destination device to “spin up” so it’s available to the rsync command.

The sleep command is to give it time to get to speed before the rsync command starts.

The -s option should be outputting a summary. The redirection should put that in the specified files.
OK, I ran the following command in terminal : sudo fdisk -l

I got a list of all the partitions I have in this machine, BUT when I look in my File manager - Dolphin, The external drive still shows as not mounted.

So, what else should I do?

Thanks
Alex
 
Old 09-16-2020, 09:57 PM   #19
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,623

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Your code is
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
change it to
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ &>> /tmp/rsync.log
or
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log 2>/tmp/rsync.err
and examine the log (or log and err) file after the next run.

Last edited by wpeckham; 09-16-2020 at 09:59 PM.
 
Old 09-17-2020, 02:56 AM   #20
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
Your code is
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
change it to
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ &>> /tmp/rsync.log
or
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log 2>/tmp/rsync.err
and examine the log (or log and err) file after the next run.
OK, I replaced the last line in the job with what you gave me:

Code:
/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log 2>/tmp/rsync.err
The backup operation ran as scheduled at 17:30, but in the /tmp folder there are no files : rsync.log, nor rsync.err

What is the reason?

Cheers
Alex
 
Old 09-17-2020, 03:58 AM   #21
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,841

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Quote:
Originally Posted by alex4buba View Post
What is the reason?
I can only suggest you to try post #3, that will give you an answer
 
Old 09-17-2020, 06:21 AM   #22
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,623

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
or change it to
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ 2>&1 |tee -a /tmp/rsync.log
and watch it run manually.

This should show AND LOG the output with error information.

Could you have scheduled this in such a way that it does not have permission to write into the /tmp folder?
For that matter, what are the permissions on your script?
How have you scheduled the run of this script?
Does that rsync.log file exist and have global read/write permissions?
I would check all of these at this point, just to cover all of the obvious bases.

PS: that the desktop is KDE is pretty much irrelevant. Scripts generally run below the level of the GUI applications when scheduled.
 
Old 09-17-2020, 07:00 AM   #23
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
or change it to
Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ 2>&1 |tee -a /tmp/rsync.log
and watch it run manually.

This should show AND LOG the output with error information.

Could you have scheduled this in such a way that it does not have permission to write into the /tmp folder?
For that matter, what are the permissions on your script?
How have you scheduled the run of this script?
Does that rsync.log file exist and have global read/write permissions?
I would check all of these at this point, just to cover all of the obvious bases.

PS: that the desktop is KDE is pretty much irrelevant. Scripts generally run below the level of the GUI applications when scheduled.
You see, because at this stage of my learning, I have no idea what matters and what not, I make a point to specify my environment, just in case.

When the instruction I had was the following, the log file was created, not it is NOT:
Code:
/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
The backup job is working fine now - just the log is not there.
The job is scheduled through the KDE task scheduler - please see attached image.

I will try the new option you gave me before the next run

Thanks again
Alex
Attached Thumbnails
Click image for larger version

Name:	backup_task.png
Views:	16
Size:	87.2 KB
ID:	34094  
 
Old 09-17-2020, 09:02 AM   #24
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Is the log file the only thing that is not working? The files are synced over?

If it is just a log file issue, take another look at my script. There is a line that first looks for a log folder, if not there it creates one. You may wish to do something like that and not use the /tmp folder. I know some distros will flush the /tmp folder after X amount of time. Found that out the hard way years back... Lost a fair amount of data. My bad. Now I just never use /tmp.

what is the output when you run the script with
Code:
bash -xvv
this will produce a very verbose output on the screen as the code runs.
 
Old 09-18-2020, 06:39 AM   #25
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,623

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Whatever you do, make sure that your logs expire, or you configure that log for logrotate, or that you manually purge them when they are no longer needed. Otherwise your log file can grow to fill your drive and crash your OS.
 
Old 09-18-2020, 06:53 AM   #26
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by wpeckham View Post
Whatever you do, make sure that your logs expire, or you configure that log for logrotate, or that you manually purge them when they are no longer needed. Otherwise your log file can grow to fill your drive and crash your OS.
I suppose if you never reboot it would be possible, but by design /tmp is cleared on every boot or reboot of the system. As with everything in linux pretty much, you can disable that setting. In addition as was suggested above, adding a file/directory check to the script, this could be done so that every time the script runs it would delete any previous files created.

https://www.google.com/search?q=does...hrome&ie=UTF-8
 
Old 09-18-2020, 07:17 AM   #27
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by HappyTux View Post
I suppose if you never reboot it would be possible, but by design /tmp is cleared on every boot or reboot of the system. As with everything in linux pretty much, you can disable that setting. In addition as was suggested above, adding a file/directory check to the script, this could be done so that every time the script runs it would delete any previous files created.

https://www.google.com/search?q=does...hrome&ie=UTF-8
Thank you.

I turn OFF my machine each night when going to sleep and turn it ON again the next morening.
If I understand correctly, the next time the job runs it will overright the previos rsync.log

Or, what log are we talking about?

Cheers
Alex
 
Old 09-18-2020, 07:41 AM   #28
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546

The ">>" syntax means append instead of overwrite. (A single ">" overwrites.)

But if the file is being deleted, appending wont help.

Save the log file to either "/var/log/rsync.log" (or /home/alex/rsync.log") to stop it being deleted.

 
Old 09-18-2020, 07:45 AM   #29
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by boughtonp View Post
The ">>" syntax means append instead of overwrite. (A single ">" overwrites.)

But if the file is being deleted, appending wont help.

Save the log file to either "/var/log/rsync.log" (or /home/alex/rsync.log") to stop it being deleted.

Sorry, not clear. Why do I need to keep it? Why should it not be overridden?

I am missing something no doubt...

Thanks
Alex
 
Old 09-18-2020, 07:51 AM   #30
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Quote:
Originally Posted by alex4buba View Post
Sorry, not clear. Why do I need to keep it? Why should it not be overridden?
The point of log files is to keep track of useful information and when something goes wrong you read them to figure out what went wrong and how fix it.

If you don't want to be able to do that then by all means continue to generate a log file that gets wiped out every day.

 
  


Reply

Tags
anacron, backup, rsync



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
copied files from SOURCE to TARGET but now want to rsync SOURCE to existing TARGET teddymills1 Linux - Newbie 3 10-28-2019 07:07 AM
rsync - not able to add suffix in copied files unclesamcrazy Linux - Newbie 3 06-22-2015 02:18 PM
ShellScript executed from command prmpt but not executed from crontab or at command BMMadhav Linux - Newbie 1 11-16-2012 07:20 PM
[SOLVED] Configured Cron job executed every hour is instead executed every minute for 10m markings Linux - Software 4 05-13-2012 05:43 PM
[SOLVED] Xwindow's program will not run when executed on boot or when executed remotely richman1234 Programming 2 10-08-2010 01:32 PM

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

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