Solved

Crontab problem...

Posted on 2008-10-29
6
633 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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