LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-26-2008, 06:27 PM   #1
Tiggy
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Rep: Reputation: 0
Question Ubuntu ... cron problem


Hi guys,

I have some problems with a cronjob I created ... running the command manually works perfectly but ones I try to run it as cron it seems show the completed msg but nothing did happen ...

Any ideas?

Crontab -e:

Quote:
# m h dom mon dow command
#* * * * * date >> /tmp/cron_test.junk
* * * * * /home/tiggy/scripts/webcam.sh >> /home/tiggy/scripts/webcam.log
That date thing works fine ...

Also created a cron.allow

Quote:
tiggy@gecko:~/scripts$ cat /etc/cron.allow
root
tiggy
But since the date thing works that shouldn't be the problem ...

Actual script (webcam.sh)

Quote:
#!/bin/sh

sudo /usr/local/bin/zmu -m 1 -i

filename="Bloemen.jpg"
hostname="users.online.be"
username="****"
password="****"

/usr/bin/ftp -in $hostname <<EOF

quote USER $username
quote PASS $password

binary
send $filename /public_html/webcam/cam1.jpg
quit
EOF

echo "Script executed successfully"
As I said ... runned manually as regular user it works ... want to run this this as a regular user btw ... didn't try it as root

Any ideas?

Last edited by Tiggy; 03-26-2008 at 06:42 PM.
 
Old 03-26-2008, 08:51 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
hmm... I'm curious as to why you have to sudo that zmu app? Maybe you should run this in root's cron instead? And are the args that you're passing in that sudo line for zmu or for sudo (I'm guessing zmu, in which case, wouldn't you want to put quotes around the command)? And how can you do a sudo without giving a password? I'll admit, I'm not that well versed in sudo, but those issues raised some warning flags for me.

Also, as a cleaner way to ftp, you may want to try ncftp. it gives a nice, command-line-friendly way to non-interactively transfer files via ftp. you would do something like

ncftpput -u $USER -p $PASS -m $HOST $REMOTE_DIR $LOCAL_FILE

Those are my ideas.


edit: oh wow, this was my 1,000th post. I'm officially a nerd now. Do I get an award or anything?

edit again: ahh... it appears I'm now listed as a "Senior Member". Break out the Champagne.

Last edited by BrianK; 03-26-2008 at 09:14 PM.
 
Old 03-27-2008, 01:46 AM   #3
Tiggy
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Original Poster
Rep: Reputation: 0
You can allow users to run certain commands as root without having to give a password (more info here: http://ubuntuforums.org/showthread.php?t=223569)

zmu is part of zoneminder; some kind of security software and that program captures images ... /dev/video0 can only be accessed by root and I don't want to change that lol

As for the ncftp ... looks nicer and easier indeed

I just wonder why it works from the command line but not if executed in crontab? Any ideas? Is there any way to log all the script and crontab does?

Thx
 
Old 03-27-2008, 01:58 AM   #4
Tiggy
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Seems like it wasn't the cron giving problems ... I did reread the sudo manual and I made some mistake there :|

Close this thread
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
ubuntu cron problems eng69 Linux - Newbie 4 02-13-2007 11:27 PM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
Synergy [vnc], ssh, cron and X from XP to Ubuntu zingfharn Linux - Software 1 03-19-2006 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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