/etc/crontab is not linked to particular user, so you have to specify the user each job is run as. This requires an additional user field to be entered right after the schedule. E.g. my system runs the cron.hourly jobs at 17 after the hour as root... (from my /etc/crontab)

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly

In general, running jobs a user or root is the norm, but you can change this by either placing scripts (or links to scripts) in one of the cron folders in /etc/ or by editing /etc/crontab...

Cheers,
Vern

Watson, Christer wrote:
Vern,

What do you mean the "system's crontab"? isn't every cron job executed by some 
user, either root or another? What user executes the system's crontab?

--Christer
________________________________________
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Vern Ceder [EMAIL 
PROTECTED]
Sent: Friday, October 24, 2008 2:03 PM
To: Fort Wayne Linux Users Group
Subject: Re: [fwlug] Geek troubles - BASH scripts and cron jobs

Simón Ruiz wrote:
Hello, all,

I know we discussed briefly that bash scripts and cron jobs interact
in less than intuitive ways.

The following cron command, for example, is in the system's cron (at
least that's what I *think* I'm editing when I do "crontab -e" as
root) of a Samba print server.

Actually, it's *root*'s crontab, the "system" crontab is /etc/crontab

0 0 * * * /root/synch_printers_from 10.0.0.7 &> /root/lastsynch.log

First of all, am I right in my guess that /root/lastsynch.log doesn't
show anything because there's a space betwen the ">" and the "/"?
Oops...

Nope, that shouldn't matter... see eg,
http://www.gnu.org/software/bash/manual/bashref.html#Redirections

More importantly, though, the "/root/synch_printers_from" script here
basically pulls down Samba and CUPS, copies over configuration files
from the target server (using scp) and then brings Samba and CUPS back
up.

However, while it seems to work perfectly every single time I run it
directly through bash it seems to fail to bring samba back up every
single time it runs as a cron job.

Does anyone have any suggestions as to where I might look for a culprit

You have full paths in the cron job, but what about within synch_printers?

Simón

Vern

_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

--
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
[EMAIL PROTECTED]; 260-436-0746; FAX: 260-436-5137

_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org


_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

--
This time for sure!
   -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
[EMAIL PROTECTED]; 260-436-0746; FAX: 260-436-5137

_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

Reply via email to