Help - Search - Members - Calendar
Full Version: Got errno 32 on write
The Planet Forums > System Administration > Web Hosting
Steveo
Just got my new linux server sorted, had it hardened by the planet. I set up a cron to execute a back up by first adding the user in cron.allow then setting the cron via WHM to execute my script ( i have used this script on another server and works fine)

However I get the following error when the cron executed.


/home/icocnser/backups/getbackups1.sh: line 1: /home/icocnser/backups/ocusa.gz: Permission denied
mysqldump: Got errno 32 on write

I test the line i put in to cron manager through SSH and works fine and does the back up.... so i guess there is a permission problem when cron does its bit.

Does anyone know why cron spits out this error?
James Jhurani
QUOTE (Steveo @ Apr 20 2008, 01:42 PM) *
Just got my new linux server sorted, had it hardened by the planet. I set up a cron to execute a back up by first adding the user in cron.allow then setting the cron via WHM to execute my script ( i have used this script on another server and works fine)

However I get the following error when the cron executed.
/home/icocnser/backups/getbackups1.sh: line 1: /home/icocnser/backups/ocusa.gz: Permission denied
mysqldump: Got errno 32 on write

I test the line i put in to cron manager through SSH and works fine and does the back up.... so i guess there is a permission problem when cron does its bit.

Does anyone know why cron spits out this error?


make sure the user the script is executing as, has permissions to read/write in /home/iconcnser/backups.

Ignore the mysqldump error, it is a result of the permission denied error before it.
Steveo
Hi

thanks for the reponse.

How can i check this?

the script i can execute in SSH fine, just cron does not work

here is what i entered into cron

QUOTE
sh /home/icocnser/backups/getbackups1.sh


I can paste that into SSH and works.

Through cron it executes the following script

QUOTE
mysqldump --user=icocnser_usauser --password=xxxxxxxx --opt icocnser_tocusa | gzip > /home/icocnser/backups/tocusa.gz


Baffling
James Jhurani
Unfortunately from my point of view, I would simply be shooting in the wind if I tried to tell you where to look.

The way I usually trouble shoot these issues is to do EXACTLY what the shell script is doing. su to that user, and start trying to do it manually. Another idea would be to put some debugging code in the script. Add a few echos, or redirect output to a file, etc... to see what line is causing it to fail

If that does not work then try running it using:
"bash -x getbackups1.sh". The -x will show you extended output:

a quick example:
CODE
[root@basic ~]# cat test.sh
#!/bin/bash
i=4
sleep 5
if [ $i -lt 5 ]
then
echo "done"
fi
[root@basic ~]# bash -x test.sh
+ i=4
+ sleep 5
+ '[' 4 -lt 5 ']'
+ echo done
done
[root@basic ~]#


Can you post your getbackups1.sh code? as well as an "ls -l" on /home/icocnser/backups/ ? Which user are you logging into the remote box as? Which user did you use to run the cron job? What output do you see in /var/log/cron when the script errors?
Steveo
When i do it manually its usually root. I su to icocnser and did the same command and it gave those errors. The sh script is owned by icocnser:icocnser.

The sh script is

CODE
mysqldump --user=icocnser_usauser --password=xxxxxxxx --opt icocnser_tocusa | gzip > /home/icocnser/backups/tocusa.gz
exit


So i guess that user connot execute those scripts.

Should I create a ticket?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.