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

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!!!!!

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)?

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

script explained, not fixed.

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.

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"

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

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.

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.

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

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

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

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