Linux Cron not Execution Shell Script

Hi Experts,
I cannot get cron to backup my Firefox settings via a shell script.

I'm running ubuntu, v 7.10 on a celeron machine.

Daily, I run Firefoxr addon FEBE which backups up Firefox settings to a file.  The name of the file created by FEBE is: profile{default}.fbu.  The file is written to /bkup/FEBE/.

I wrote a shell script to copy profile{default}.fbu to another directory and append the Date -Time(YYYYMMDD-HHMMSS) to the file so it will not be over written the next day.   The shell script is shown below:

mv /bkup/FEBE/profile*.fbu  /bkup/FEBE/daily/profile{default}.fbu-$(date +"%Y.%m.%d-%H.%M.%S")

I can successfully run the script from the command prompt, but I cannot get cron to execute it.  

Services anacron and atd are running.  I used KCron to  to set up cron.

The attached screen shot shows more information:

1. upper left - name and location of shell script
2. upper middle - KCron setup (not setup while root)
3. upper right - anacron service
4. bottom left - location and name of file to be backed up (created by Firefox FEBE)
5. bottom middle - shell script code - - note I use a "*"  to generalize file name in shell script

Can you see what I have done wrong?

Thanks much.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Please note that to run scripts as crontab jobs, you need:

- Set all required env variables in the script itself. e.g.

PATH=/usr/bin ; export PATH

- When you refer to commands or files please use full pathnames . e.g.



These are used in your script.

- Redirect command output to a file to see results or errors. By default it is sent as mail to the user. You may check you email with mail command.

To redirect output:

/path/to/command >> /path/to/command.log 2>&1


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Take a look at /var/log/cron and see if there are any errors.  The script has to be marked as executable (chmod 750 <script>), and cron can be picky about permissions.  If there is a permissions problem then it tell you exactly what is wrong in the log file.
in your crontab use something like:

1 1 * * * /bin/mv "/bkup/FEBE/profile{default}.fbu"  "/bkup/FEBE/daily/profile{default}.fbu-$(date +'%Y.%m.%d-%H.%M.%S')"

Note, that you most likely cannot copy /bkup/FEBE/profile*.fbu to one single file 'cause it overwrites the same destination file, obviously ...
IT79637Author Commented:
Thanks experts!

My Firefox settings backup works.  I took advice from all three posts:
1. use full path names before "command".
2. added env variable PATH to script.
3. removed the "wild card" character from the file name.
4. added package mailx and can check my mail for success/failure.
5. added my own log to track success or failure by testing $? and outputing the return variable to a file and naming it appropriately.

I know this is a bit over kill, but it was a good exercise.

Thanks much!!!

/bin/mv /bkup/FEBE/profile{default}.fbu  /bkup/FEBE/daily/profile{default}.fbu-$(date +"%Y.%m.%d-%H.%M.%S")
if [ $? -eq 0 ];
    echo $? > /home/user/software/scripts/status.txt
    /bin/mv  status.txt /home/user/software/scripts/log/success.txt-$(date +"%Y.%m.%d-%H.%M.%S")
    echo $? > /home/user/software/scripts/status.txt
    /bin/mv  status.txt /home/user/software/scripts/log/failure.txt-$(date +"%Y.%m.%d-%H.%M.%S")

Open in new window

IT79637Author Commented:
Thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.