LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2010, 12:52 PM   #1
ifeatu
Member
 
Registered: Sep 2008
Distribution: Fedora 9
Posts: 68

Rep: Reputation: 15
Cron Job keeps failing


Hey

My cron job to backup shares keeps failing:

It keeps saying...

mkdir: cannot create directory `/mnt/usbdrive/backups/20100202': Permission deni
ed

but I DO have permission with my user pmalbrough

X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/pmalbrough>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=pmalbrough>
X-Cron-Env: <USER=pmalbrough>


I run mkdir /mnt/usbdrive/backups/20100202 from the shell prompt and it works fine!

I even went so far as to put the user pmalbrough in the group root.

$groups
root IT

#Here is the permissions for the "backups" dir on /mnt/usbdrive
ls -l
total 8
drwxrwxr-x 4 root root 4096 Feb 3 10:45 backups


and here is my script:

Code:
#! /bin/bash
echo Backup Started `date` >> ~/backuplog
mkdir /mnt/usbdrive/backups/`date +%Y%m%d`
tar -czf /media/disk/backups/`date +%Y%m%d`/home_drive.tar.gz /home
tar -czf /media/disk/backups/`date +%Y%m%d`/Software.tar.gz /shares/samba/softwa
re
tar -czf /media/disk/backups/`date +%Y%m%d`/Public.tar.gz /ahd/test_restores/01-
22-09/public
echo Backup Completed `date` >> ~/backuplog
 
Old 02-03-2010, 01:08 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Why is an account for a human admin user being used for scheduled backups of system data? That's horrible. Use the system crontab in /etc/crontab.
 
2 members found this post helpful.
Old 02-03-2010, 02:54 PM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
acid_kewpie is right to say that this should be done under the system account. Marking his thread as unhelpful is counter productive.

Additionally, you should consider a few revisions to the script:
Code:
#! /bin/bash
echo Backup Started `date` >> ~/backuplog
l_backup_dir=/mnt/usbdrive/backups/$(date +%Y%m%d)
if [ -d ${l_backup_dir} ]
then
   echo "Directory ${l_backup_dir} already exists" >> ~/backuplog
else
   if [ -d /mnt/usbdrive/backups ]
   then
      mkdir ${l_backup_dir}
      tar -czf ${l_backup_dir}/home_drive.tar.gz /home
      tar -czf ${l_backup_dir}/Software.tar.gz /shares/samba/software
      tar -czf ${l_backup_dir}/Public.tar.gz /ahd/test_restores/01-22-09/public
   else
      echo "Directory /mnt/usbdrive/backups not found!" >> ~/backuplog
      echo "USB drive may not be mounted!" >> ~/backuplog
   fi
fi
echo Backup Completed `date` >> ~/backuplog
 
1 members found this post helpful.
Old 02-04-2010, 01:04 AM   #4
Dave_Devnull
Member
 
Registered: May 2009
Posts: 142

Rep: Reputation: 24
I suspect the issue is his bedside manner - 33,814 posts - thanked 221 . That sharp tongue of his will cut his own throat one day. He may be entirely unaware of just how rude he is, but it's extremely offensive and condescending.

Last edited by Dave_Devnull; 02-04-2010 at 01:09 AM.
 
0 members found this post helpful.
Old 02-04-2010, 01:22 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
I think you may find that there are a number of other contributing factors to the high post to thanks ratio.

The thanks option is a relatively recent addition to LQ.

Acid_kewpie will have made a large number of posts before the option was available.

These days, with the "Helpful/Unhelpful" indicator being adopted for individual threads, less people are using the Thanks button.

Moderators need to maintain the systems, moving threads to the relevant section, and ensuring the LQ rules are adhered to. These things rarely earn thanks.
 
1 members found this post helpful.
Old 02-04-2010, 02:19 AM   #6
Dave_Devnull
Member
 
Registered: May 2009
Posts: 142

Rep: Reputation: 24
Indeed, but the vast majority of his replies are rude and condescending - and pretty shameful when posted in a Newbies section. Perhaps he needs to take a break (preferably his nose or face).
 
Old 02-04-2010, 12:46 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Hmm, nice. Thanks for that. You might want to not be so directly offensive to anyone on this forum or you may well not have the opportunity in future.

While my replies may be a little short, I would not wish physical injury on anyone.

Last edited by acid_kewpie; 02-04-2010 at 12:50 PM.
 
Old 02-04-2010, 01:04 PM   #8
Dave_Devnull
Member
 
Registered: May 2009
Posts: 142

Rep: Reputation: 24
[mod_edit]language cleanup[/mod_edit]

Last edited by Tinkster; 02-04-2010 at 02:33 PM. Reason: see above
 
0 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 08:52 PM
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 job somsahi Linux - Software 9 10-05-2006 02:19 PM
cron failing do to path/permission issues azwebco Programming 1 08-04-2006 06:25 AM
CRON Job tommytomato Fedora 12 09-13-2004 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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