Solved

Crontab problem...

Posted on 2008-10-29
6
629 Views
Last Modified: 2013-12-16
I don't know how to start... don't know why is happening... but here it goes...


I have set up webcam on linux, and I wanted to automate the process, so I found a page with two files one to stop the webcam and the other to start it, to be on the safe side it should be run at midnight pss some minutes.. using crontab...

ok if I run the program from the console, the images are created with 664 permissions wich that's what I want and it should be, since the program is executed by the user and it is in the user bin folder /home/user/bin and images are stored in a user's folder /home/user/pics

but if I set up cron...

crontab -u user -e

<vars>
<whatever>
<path add path to bin's user> {either this or...}

* * * * * /home/user/bin/webcamstart {this is the same I think and both are declared}


Why cron thinks like the executor is root??? or why does it change it from 664 to 644???


I  hope I made my self clear...
0
Comment
Question by:My name is Mud
6 Comments
 
LVL 6

Author Comment

by:My name is Mud
ID: 22838652
Oh forgot to mention that I didn't knew the /etc/crontab fileshouldn't be edited manually, which I did and put something like


* * * * * user /home/user/bin/webcamstart



This is the real cronfile for user...
SHELL=/bin/sh
HOME=/home/user
PATH=/usr/bin:/bin:/home/user/bin
LOGNAME=user
USER=user

02 00 * * * /home/user/bin/webcamstop
03 00 * * * /home/user/bin/webcamstart
06 00 * * * /home/user/bin/mkmovie
* * * * * /home/user/bin/createmask

Webcamstart starts the webcam and all images are 644 instead of 664 as well as mkmovie which starts the mencoder to create a movie out of the files from yesterday folder... and again, movie is 644 instead of 664... so what am I doing wrong???
0
 
LVL 6

Author Comment

by:My name is Mud
ID: 22838656
oh and puting manually the comands in crontab did work with the same results as root...
0
 
LVL 48

Accepted Solution

by:
Tintin earned 100 total points
ID: 22839019
You need to set the umask, eg:

03 00 * * * umask 002 ;  /home/user/bin/webcamstart
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 25 total points
ID: 22841257
As Tintin recommended, it is because of the umask of the process that runs the command. I think in your user profile you are setting umask to 002 while when crontab is run it uses the default umask of 022
0
 
LVL 8

Expert Comment

by:eager
ID: 22841722
Don't set umask in crontab.  Set permissions in the script.
0
 
LVL 6

Author Closing Comment

by:My name is Mud
ID: 31511562
Thanks to both...
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question