LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-24-2008, 01:23 AM   #1
tkahhaw
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Rep: Reputation: 0
Crontab sudo


I hope this is the correct place to ask this question:

OS: SUSE Linux SP2

1)I am logging in as a nonroot user namely alvin
2)I have a backup scripts that can run by alvin without any problem.
3)Inside this backup scripts, I did use sudo.
4)I have configure sudo without password.
5)I put in crontab as below:
------------------------------------------------------
alvin@ambglx01:~> crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXXzzsPk installed on Mon Nov 24 14:56:37 2008)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
30 14 * * * /home/alvin/idm-eDirBackup.sh
---------------------------------------------------------


IT cannot work, there is a message in /var/opt/mail/alvin, saying that sudo command not found:
----------------------------------------------
alvin@ambglx01:~> tail -f /var/mail/alvin
Creating Backup Files...
/home/alvin/idm-eDirBackup.sh: line 5: sudo: command not found
Backup Files Created!!!!
/home/alvin/idm-eDirBackup.sh: line 8: sudo: command not found
Tar file idm-eDirBackup24112008.tar.gz created!!!
Creating log file...
ls: /home/alvin/backup/idm-eDirBackup24112008.tar.gz: No such file or directory
Log file created.
Backup of eDirectory Completed
-----------------------------------------------

Please help
 
Old 11-24-2008, 01:29 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Try putting the path to sudo in the script, so instead of

sudo some_command

try

/usr/bin/sudo some_command

Check the path first.
 
Old 11-24-2008, 02:38 AM   #3
tkahhaw
LQ Newbie
 
Registered: Dec 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by billymayday View Post
Try putting the path to sudo in the script, so instead of

sudo some_command

try

/usr/bin/sudo some_command

Check the path first.
Yes it works if I do it that way. haha.

TQ very much
 
Old 11-24-2008, 02:43 AM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
It's because cron doesn't inherit your path that you had the problem in the first place.
 
  


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
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
LXer: sudo, or not sudo: that is the question LXer Syndicated Linux News 0 02-07-2008 05:40 PM
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 03:20 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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