LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-26-2007, 08:23 AM   #1
Timur Sakayev
LQ Newbie
 
Registered: Dec 2004
Location: Fairfield, CT
Distribution: Mandrake, SUSE, RH
Posts: 21

Rep: Reputation: 15
script doesn't run in cron (runs from shell just fine)


Hello everybody,

Here is my problem this time (i've found this community very helpful, but have yet to be able to give back to the community, due to my limited knowledge). As always, seems to be very simple, and it probably is something minor that i'm missing.

I wrote this one shell script that downloads file from another machine using scp. When i run it from shell - everything works just fine, but when i put it into crontab, it refuses to run. There are no environment variables involved - the script is literally three lines. The accounts are set up so that there is no password needed to log in (via keys in .ssh)
Code:
#/bin/bash
cd /storage
scp -r bckup_user@caesar:/home/bckup_user/svn_backup/ svn_backup
chown -R bckup_user:users svn_backup/*
When i look at the log, here is what i see
Code:
Feb 23 09:30:01 phoenix /usr/sbin/cron[21767]: (bckup_user) CMD (/usr/local/scripts/svn_backup.sh > /tmp/svn-log.txt)
Feb 23 09:30:02 phoenix /usr/sbin/cron[21766]: (bckup_user) UNSAFE (bckup_user)
I tried to google for "UNSAFE" part, but didn't come up with anything.

Any ideas are welcome.

Thanks in advance!

TS
 
Old 02-26-2007, 09:39 AM   #2
asommer
Member
 
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
My guess is that you may need to include the full path to the script in your cron entry.. At least that's one problem I've had with placing shell scripts into cron.

Had my executable in /usr/local/bin but it just wouldn't run from cron. Until I added the /usr/local/bin to the cron entry...smooth sailing after that.
 
Old 02-26-2007, 09:45 AM   #3
Timur Sakayev
LQ Newbie
 
Registered: Dec 2004
Location: Fairfield, CT
Distribution: Mandrake, SUSE, RH
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks, asommer!

This doesn't seem to be the problem as i use the absolute path in the crontab.

Any other possible ideas?

TS
 
Old 02-26-2007, 09:55 AM   #4
asommer
Member
 
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
Are you using absolute paths in your script? Do you have selinux or anything like that enabled?
 
Old 02-26-2007, 09:57 AM   #5
asommer
Member
 
Registered: Mar 2003
Location: North Carolina
Distribution: Gentoo
Posts: 168

Rep: Reputation: 30
I just found this article after looking closer at the output you posted:

http://www-gatago.com/comp/unix/admin/2447745.html

Does this sound close to what you're seeing?
 
Old 02-26-2007, 10:00 AM   #6
Timur Sakayev
LQ Newbie
 
Registered: Dec 2004
Location: Fairfield, CT
Distribution: Mandrake, SUSE, RH
Posts: 21

Original Poster
Rep: Reputation: 15
oh yeah, the script uses absolute paths too.

Yup, that's what it looks like in the log. And the username does have an underscore in it. Let me test it under a different username and see if that helps, and i'll get back here ASAP.

Thanks for the info.

TS
 
Old 02-26-2007, 12:56 PM   #7
Timur Sakayev
LQ Newbie
 
Registered: Dec 2004
Location: Fairfield, CT
Distribution: Mandrake, SUSE, RH
Posts: 21

Original Poster
Rep: Reputation: 15
Well,

I just tried to run the script in crontab under a different user (without an underscore in the name) - it looks like it runs fine. so, i guess, no weird characters in the name of automatic users.


TS
 
  


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
php script will not run correctly as cron, fine from cli dtra Linux - Software 2 12-22-2005 07:21 AM
cron issue, php script runs fine in browser and cli dtra Linux - Software 1 07-15-2005 05:45 AM
run shell script on cron varunbihani Linux - Newbie 5 07-08-2005 01:50 AM
script runs fine from a command line, but doesn't work from cron? kleptophobiac Linux - Software 5 05-03-2004 04:14 PM
shell script fo run auto job in cron JolynnMarie LinuxQuestions.org Member Intro 0 04-28-2004 11:21 AM


All times are GMT -5. The time now is 04:13 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration