Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-Oct-2009, 04:52
eeijlar's Avatar
Explorer Penguin
 
Join Date: Jun 2008
Location: Dublin, Ireland
Posts: 245
eeijlar hasn't been rated much yet
Default Backup script

Hi,

I have a backup script to back up a mysql database. I have it setup up as a cron job. I am getting mails from cron like:

Code:
 
Date: Mon,  1 Jun 2009 22:00:07 +0100 (IST)

/bin/sh: /home/user/scripts/backup.sh: Permission denied
Do I have to be root to run the script? I thought cron jobs ran as root anyway... Should they be root? Is that a bad idea...?

Suggestions welcome..

/jlar
Reply With Quote
  #2 (permalink)  
Old 01-Oct-2009, 05:01
microchip8's Avatar
Shaman Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 2,204
microchip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the rough
Default Re: Backup script

did you make it executable?
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #3 (permalink)  
Old 01-Oct-2009, 05:35
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,913
hcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enough
Default Re: Backup script

Cron jobs run for the user who set them in their crontabs. So when you edited as root the root crontab, it will run as root. But when you edited as enduser the crontab of enduser, it runs under enduser.

The crontab entries in /etc/cron.* are run under root (enduser wouldn't have the permission to create something there).

A backup run for a MySQL database should eithet be owned/run by user mysql or root. When mysql can do everything you shouldn't do it as root (old wisecrack).

And of course when you mention something to be executed from any crontab that owner must have read and execute access to that file. So some r and x bits in the right places might be handy like microchip8 suggested allready.
__________________
Henk van Velden
Reply With Quote
  #4 (permalink)  
Old 01-Oct-2009, 06:18
eeijlar's Avatar
Explorer Penguin
 
Join Date: Jun 2008
Location: Dublin, Ireland
Posts: 245
eeijlar hasn't been rated much yet
Default Re: Backup script

It wasn't executable - doh! Thanks everyone for their help..
Reply With Quote
  #5 (permalink)  
Old 01-Oct-2009, 06:58
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,913
hcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enough
Default Re: Backup script

What I do not understand is how you tested it. Trying to run it directly (not in cron) must gave the same problem.
__________________
Henk van Velden
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2