Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 22nd, 2011, 02:32 AM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Scheduled cron job stopped working

Hi

I run a Fedora 9 server at home, to host an "old school" MOO.

To back up the database, I scheduled a cron job - and got some help with the script.

Code:
#!/bin/bash

FILENAME="muddle_`date +%Y-%m-%d_%H:%M`.db.new"
cp /home/xxxxx/mooxxx/bin/muddle.db.new "/home/xxxxx/mooxxx/bin/$FILENAME"
mv "/home/xxxxx/mooxxx/bin/$FILENAME" /root/Dropbox/


That worked fine over about a year, till sometime in May, when it just stopped working.

The error is:
Code:
mv: cannot stat `/root/Dropbox/muddle_2011-08-22_17:12.db.new': Permission denied


I don't fiddle with stuff on the server much, because I don't really have a clue - leave well enough alone.

But now I'm without backups. (I'd prefer to get this working, as it seemed pretty simple, and worked well for so long).

Anyy suggestions?

Woger

Last edited by woger : August 22nd, 2011 at 05:21 AM.

Reply With Quote
  #2  
Old August 22nd, 2011, 03:57 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
The major hints are the 'cannot stat' - which generally means 'cannot find' and the 'permission denied' which generally means what it says.
Could be a few things, which would require you to check the permissions of files and directories. But, one additional thing that springs to mind is that whilst you are moving your backups into the /root/Dropbox directory you do not mention doing any housekeeping. You may also wish to check how full the /root file system is.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old August 22nd, 2011, 04:18 AM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Thank you...hopefully I can answer your suggestions intelligently.

I ran a ls -l to get permissions. Here's where they are at:

Code:
drwx------ 4 root root 16384 2011-08-22 19:01 Dropbox
-rwxrwxrwx 1 root  root       206 2011-08-22 17:20 back.sh


With regard to housekeeping - I'm not sure what I need to do? All going well, once the file is moved to the dropbox directory, it automatically gets uploaded. I do remove files from the local dropbox intermittently. Dropbox has never exceeded about 58% capacity - each file is now approaching 6mb

Hopefully that gives the Linux epxerts some clues to help me out - way over my head here!!!!!

woger

Last edited by woger : August 22nd, 2011 at 04:53 AM.

Reply With Quote
  #4  
Old August 25th, 2011, 08:56 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
This script is part of the root crontab?
What happens if you run it by hand using: bash -x back.sh (assuming back.sh is the script in question)?

Reply With Quote
  #5  
Old August 25th, 2011, 08:22 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 29 sec
Reputation Power: 383
script explained, not fixed.

Code:
0  #!/bin/bash

1  FILENAME="muddle_`date +%Y-%m-%d_%H:%M`.db.new"
2  cp /home/xxxxx/mooxxx/bin/muddle.db.new /root/Dropbox/"$FILENAME"



Line 0 tells the command line interpreter to invoke /bin/bash to read the script.

Line 1 sets the shell variable FILENAME to the string on the right side of the assignment token (=).
However, the string is double quoted and therefore subject to some further expansions. The output (stdout) of the date command between back-quotes is substituted for the `back tick command`. Back-ticks are depricated. Use $( command ) instead. Why bother to quote the phrase at all? The stuff between the quotes is one word even if it contains space characters.

Line 2 copies the file directly to /root/Dropbox with the new name. I cannot think of a reason to copy the file and then move it, so I changed your script. There's a good chance /root/Dropbox and /home/me are on different file systems and so the commands in your script would effectively copy the file twice. At least I'm pretty sure that's how it works. But anyway, lastly, $FILENAME substitutes the value of the variable. And since in double quotes retains the single word business.

'Single quoted strings in the shell script' are one word, nothing gets substituted.

Reply With Quote
  #6  
Old August 27th, 2011, 01:44 AM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Still not a lot of luck... Although perhaps some progress.

I modified the script first.

Code:
#!/bin/bash
FILENAME="muddle_date +%Y-%m-%d_%H:%M.db.new"
#cp /home/basil/moo3/bin/muddle.db.new "/home/basil/moo3/bin/$FILENAME"
#mv "/home/basil/moo3/bin/$FILENAME" /root/Dropbox/
cp /home/basil/moo3/bin/muddle.db.new /root/Dropbox/"$FILENAME"


The error this time was: cp: accessing `/root/Dropbox/xxxxe_date +%Y-%m-%d_%H:%M.db.new': Permission denied

I then tried to run it from the command line.
Code:
[root@bin]# bash -x back.sh
+ FILENAME='xxxxx_date +%Y-%m-%d_%H:%M.db.new'
+ cp /home/xxxx/xxxx/bin/xxxxx.db.new '/root/Dropbox/xxxxx_date +%Y-%m-%d_%H:%M.db.new'


That has copied the file, and dropbox has done it's thing. But the file name appears as-
Code:
xxxx_date +%Y-%m-%d_%H:%M.db.new
rather than appending the date to the the datbase name.

Hope that makes sense.

Reply With Quote
  #7  
Old August 27th, 2011, 04:13 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
You've altered the date command, and removed the 'command ticks' to get the shell to recognise it as a command. You should go back to using ` .. ` or better, as suggested by b49P23TIvg use $( .. )
FILENAME="muddle_$(date +%Y-%m-%d_%H:%M).db.new"

Reply With Quote
  #8  
Old August 27th, 2011, 05:18 AM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Quote:
Originally Posted by SimonJM
You've altered the date command, and removed the 'command ticks' to get the shell to recognise it as a command. You should go back to using ` .. ` or better, as suggested by b49P23TIvg use $( .. )
FILENAME="muddle_$(date +%Y-%m-%d_%H:%M).db.new"

Gotcha. So that runs fine from command line. But how do I get cron to run it automatically. It still says permission denied.

Reply With Quote
  #9  
Old August 27th, 2011, 10:35 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
OK, so we have a script that functions correctly when called from the command line? That's a good start!
Now, can you confirm that the user you use to run the script at the command line is the samr as the user running it via cron? The raeson I ask is that your Dropbox directory is only available to the root user and I'd suspect that your moo runs under another user, which makes me think your backup also runs as that user (basil) which will cause permission issues.
If the script is running from cron as as user other than root then wel will need to make some changes - I'd suggest either changing Dropbox so that it is owned by the relevant user or look into setting up a group and giving that rwx access to Dropbox and adding the user that runs the moo and/or the script into the group.

Reply With Quote
  #10  
Old August 27th, 2011, 05:29 PM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
It was setup over 12 months ago, but....

The script runs from a directory under basil.
(I was trying to avoid security issues by running as root).
But permissions wise, I set it up as:

Code:
-rwxrwxrwx 1 root  root       274 2011-08-27 20:11 back.sh


And , yes, for some reason, dropbox is installed under root. But I think that's because that's the only way I could get webmin to work. (I'm not really good at CLI - so i look for GUIs).

Permissions wise though, this did work for over 12 months. Basil does belong to an admin group.

Cheers

Reply With Quote
  #11  
Old August 27th, 2011, 08:02 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 29 sec
Reputation Power: 383
Out of date, but still useful?

This post is a response to

Today, 02:44 AM
woger Contributing User

sorry, screwy internet? screwy me? screwy Irene? (the local hurricane, for those of you reading this message in the far future when you're dealing with different weather issues, or from other countries where you have super typhoons.)

FILENAME="muddle_$( date +%Y-%m-%d_%H:%M.db.new )"

I thought my explanation was rather good. Perhaps you'd read the whole thing? And, so as to be not completely snotty, you can experiment on the command line with commands like

echo FILENAME="muddle_$( date +%Y-%m-%d_%H:%M.db.new )"

echo '$( date )' "$( date )" $( date ) computation $(( 38+2342 ))

Last edited by b49P23TIvg : August 27th, 2011 at 08:56 PM. Reason: this post is out of date

Reply With Quote
  #12  
Old August 27th, 2011, 08:21 PM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Quote:
Originally Posted by b49P23TIvg
FILENAME="muddle_$( date +%Y-%m-%d_%H:%M.db.new )"

I thought my explanation was rather good. Perhaps you'd read the whole thing? And, so as to be not completely snotty, you can experiment on the command line with commands like

echo FILENAME="muddle_$( date +%Y-%m-%d_%H:%M.db.new )"

echo '$( date )' "$( date )" $( date ) computation $(( 38+2342 ))

Thanks. From the CLI - as you suggest - that's fine.
Learnt a few things there.

Permission error still from cron.

Reply With Quote
  #13  
Old August 27th, 2011, 10:15 PM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
Strange, and sorry to get you to do CLI stuff (which I prefer!) instead of GUI stuff

Rats ... let's try that command again ...

Code:
FILENAME=muddle_$(date "+%Y-%m-%d_%H:%M").db.new

Is, I think, what you should be using. Hopefully, from the command line (sorry!) you do what b49P23TIvg suggests, as a debug aid, and replicate the command but using echo:
Code:
echo muddle_$(date "+%Y-%m-%d_%H:%M").db.new

you should be able to confirm it will be doing what you want.
Likewise, running the script from the command line using bash -x which will show how each line is evaluated will help confirm it is working when within the script.
Once we have all those 'ducks lined up' we get to the nub of the problem, which is why it causes an error when run as cron.
Can you show us (sanitised if you wish) output from the commands:
Code:
crontab -u root -l
crontab -u basil -l

Reply With Quote
  #14  
Old August 27th, 2011, 10:28 PM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
Code:
Can you show us (sanitised if you wish) output from the commands:
[CODE]crontab -u root -l
crontab -u basil -l
[/QUOTE]

Results from CLI -

[root@sbc ~]# crontab -u root -l
20 3 * * * /etc/webmin/cron/tempdelete.pl
[root@sbc ~]# crontab -u basil -l
@daily /home/xxxx/moo3/bin/back.sh
[root@sbc ~]#

Reply With Quote
  #15  
Old September 8th, 2011, 01:21 AM
woger woger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 325 woger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 5 h 5 m 8 sec
Reputation Power: 9
The problems seem to be:

My MOO doesn't run as root - for security reasons.

And CRON needs to (or so I thought). Any suggestions to be able to get the cron job working again?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Schedluled cron job stpped working

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap