Re: Probably working too hard for this cron question

2011-06-14 Thread Warren Block

On Mon, 13 Jun 2011, Kurt Buff wrote:


Per the handbook, I added

SHELL=/bin/sh

to crontab, and I also added

#!/bin/sh

as the first line in the script


Should not need both.  The first changes a default, which is bad when 
you switch to another system where that hasn't been changed.  The 
second, putting #!/bin/sh in the script, should be enough.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread Kurt Buff
On Mon, Jun 13, 2011 at 15:02, Polytropon  wrote:
> On Mon, 13 Jun 2011 14:44:29 -0700, Kurt Buff  wrote:
>> Per the handbook, I added
>>
>>      SHELL=/bin/sh
>>
>> to crontab, and I also added
>>
>>      #!/bin/sh
>>
>> as the first line in the script
>>
>> But, while a file is being created, it's just
>>
>>      /root/-external1.txt
>>
>> not
>>
>>      /root/2011-06-13-external1.txt
>
> Just a wild guess: How about adding {} to the variable
> identifiers? There are some restrictions in how far a
> character following the variable name will be treated
> as a "stop sign", e. g. variable x, literal y, and you
> have $xy which won't work, but $x_y may work, so you
> use ${x}y to make sure the name is properly scoped.
>
> Refering to your original script:
>
> #!/bin/sh
> dt=`/bin/date "+%Y-%m-%d"`
> /bin/date > /root/${dt}-external1.txt
> /usr/local/bin/curl -K /root/urls.txt >> /root/${dt}-external1.txt
> /bin/date >> /root/${dt}-external1.txt
>
> Could you try that?

Can, and did, and it works like a champ. That solves the last issue.



My thank to you Polytropon, and to those who replied privately.

Now all I have to do is pin down whether the name resolution slowness
is in our firewall, or web filter, or external router, or perhaps
something at the ISP.

Kurt
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread Daniel Feenberg


I forgot to send it. I just did.

dan

On Mon, 13 Jun 2011, Kurt Buff wrote:


Indeed. Brain fade comes with age - and long weekends with the 2 year old boy...

Kurt

On Mon, Jun 13, 2011 at 14:14, Gary Gatten  wrote:

Yeah Pete, kinda need that huh.  Kurt, If that turns out to be the only issue, 
don't feel bad - I've forgotten it myself several times!  I'm sure many others 
have as well!

G


-Original Message-
From: owner-freebsd-questi...@freebsd.org 
[mailto:owner-freebsd-questi...@freebsd.org] On Behalf Of pete wright
Sent: Monday, June 13, 2011 3:25 PM
To: Kurt Buff
Cc: FreeBSD Questions
Subject: Re: Probably working too hard for this cron question

On Mon, Jun 13, 2011 at 12:52 PM, Kurt Buff  wrote:

All,

I've googled a bunch, read some freebsd.org docs, and just can't
figure this out.

I have a script that should read the current date into a variable,
append the time/date stamp at the beginning of the file created with
the date in the variable, do a bunch of cURL stuff, then append a
time/date stamp at the end of the file.

It works if I run it manually, but not from cron.

Here are the batchfile and the cron entry:

--begin script--
dt=`/bin/date "+%Y-%m-%d"`
/bin/date > /root/$dt-external1.txt
/usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
/bin/date >> /root/$dt-external1.txt
--end script--

--begin crontab--
15 12 * * *        /root/do-curl.sh
--end crontab--

I'm doing all of this as root, as you can see.

The job launches - I can see an entry for cURL in top - but no file in /root.

I've tried several variations on the first line of the script, but I'm
getting nowhere, though I'm sure it's something stupidly simple that
I'm missing.

What am I missing?


#!/bin/sh ?

-pete



--
pete wright
www.nycbug.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"








"This email is intended to be reviewed by only the intended recipient
 and may contain information that is privileged and/or confidential.
 If you are not the intended recipient, you are hereby notified that
 any review, use, dissemination, disclosure or copying of this email
 and its attachments, if any, is strictly prohibited.  If you have
 received this email in error, please immediately notify the sender by
 return email and delete this email from your system."




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Re: Probably working too hard for this cron question

2011-06-13 Thread Polytropon
On Mon, 13 Jun 2011 14:44:29 -0700, Kurt Buff  wrote:
> Per the handbook, I added
> 
>  SHELL=/bin/sh
> 
> to crontab, and I also added
> 
>  #!/bin/sh
> 
> as the first line in the script
> 
> But, while a file is being created, it's just
> 
>  /root/-external1.txt
> 
> not
> 
>  /root/2011-06-13-external1.txt

Just a wild guess: How about adding {} to the variable
identifiers? There are some restrictions in how far a
character following the variable name will be treated
as a "stop sign", e. g. variable x, literal y, and you
have $xy which won't work, but $x_y may work, so you
use ${x}y to make sure the name is properly scoped.

Refering to your original script:

#!/bin/sh
dt=`/bin/date "+%Y-%m-%d"`
/bin/date > /root/${dt}-external1.txt
/usr/local/bin/curl -K /root/urls.txt >> /root/${dt}-external1.txt
/bin/date >> /root/${dt}-external1.txt

Could you try that?

As you mentioned ${dt} would be empty upon cron
execution, but not when run interactively, I would
guess that the execution of a value assignment keeps
its value just as long as it is within the same shell
environment (unless you set an environmental variable
via export command). If the script would be executed
by cron with one shell call per line... but I think
that it isn't done that way as it sounds too wrong...




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread Kurt Buff
Indeed. Brain fade comes with age - and long weekends with the 2 year old boy...

Kurt

On Mon, Jun 13, 2011 at 14:14, Gary Gatten  wrote:
> Yeah Pete, kinda need that huh.  Kurt, If that turns out to be the only 
> issue, don't feel bad - I've forgotten it myself several times!  I'm sure 
> many others have as well!
>
> G
>
>
> -Original Message-
> From: owner-freebsd-questi...@freebsd.org 
> [mailto:owner-freebsd-questi...@freebsd.org] On Behalf Of pete wright
> Sent: Monday, June 13, 2011 3:25 PM
> To: Kurt Buff
> Cc: FreeBSD Questions
> Subject: Re: Probably working too hard for this cron question
>
> On Mon, Jun 13, 2011 at 12:52 PM, Kurt Buff  wrote:
>> All,
>>
>> I've googled a bunch, read some freebsd.org docs, and just can't
>> figure this out.
>>
>> I have a script that should read the current date into a variable,
>> append the time/date stamp at the beginning of the file created with
>> the date in the variable, do a bunch of cURL stuff, then append a
>> time/date stamp at the end of the file.
>>
>> It works if I run it manually, but not from cron.
>>
>> Here are the batchfile and the cron entry:
>>
>> --begin script--
>> dt=`/bin/date "+%Y-%m-%d"`
>> /bin/date > /root/$dt-external1.txt
>> /usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
>> /bin/date >> /root/$dt-external1.txt
>> --end script--
>>
>> --begin crontab--
>> 15 12 * * *        /root/do-curl.sh
>> --end crontab--
>>
>> I'm doing all of this as root, as you can see.
>>
>> The job launches - I can see an entry for cURL in top - but no file in /root.
>>
>> I've tried several variations on the first line of the script, but I'm
>> getting nowhere, though I'm sure it's something stupidly simple that
>> I'm missing.
>>
>> What am I missing?
>
> #!/bin/sh ?
>
> -pete
>
>
>
> --
> pete wright
> www.nycbug.org
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
>
>
>
>
>
> 
> 
> 
> "This email is intended to be reviewed by only the intended recipient
>  and may contain information that is privileged and/or confidential.
>  If you are not the intended recipient, you are hereby notified that
>  any review, use, dissemination, disclosure or copying of this email
>  and its attachments, if any, is strictly prohibited.  If you have
>  received this email in error, please immediately notify the sender by
>  return email and delete this email from your system."
> 
>
>
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread Kurt Buff
On Mon, Jun 13, 2011 at 13:25, pete wright  wrote:
> On Mon, Jun 13, 2011 at 12:52 PM, Kurt Buff  wrote:
>> All,
>>
>> I've googled a bunch, read some freebsd.org docs, and just can't
>> figure this out.
>>
>> I have a script that should read the current date into a variable,
>> append the time/date stamp at the beginning of the file created with
>> the date in the variable, do a bunch of cURL stuff, then append a
>> time/date stamp at the end of the file.
>>
>> It works if I run it manually, but not from cron.
>>
>> Here are the batchfile and the cron entry:
>>
>> --begin script--
>> dt=`/bin/date "+%Y-%m-%d"`
>> /bin/date > /root/$dt-external1.txt
>> /usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
>> /bin/date >> /root/$dt-external1.txt
>> --end script--
>>
>> --begin crontab--
>> 15 12 * * *        /root/do-curl.sh
>> --end crontab--
>>
>> I'm doing all of this as root, as you can see.
>>
>> The job launches - I can see an entry for cURL in top - but no file in /root.
>>
>> I've tried several variations on the first line of the script, but I'm
>> getting nowhere, though I'm sure it's something stupidly simple that
>> I'm missing.
>>
>> What am I missing?
>
> #!/bin/sh ?

Definitely closer...

Per the handbook, I added

 SHELL=/bin/sh

to crontab, and I also added

 #!/bin/sh

as the first line in the script

But, while a file is being created, it's just

 /root/-external1.txt

not

 /root/2011-06-13-external1.txt

Kurt
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread pete wright
On Mon, Jun 13, 2011 at 2:14 PM, Gary Gatten  wrote:
> Yeah Pete, kinda need that huh.  Kurt, If that turns out to be the only 
> issue, don't feel bad - I've forgotten it myself several times!  I'm sure 
> many others have as well!
>

as someone who was fixing some brain dead cron entries he setup on
friday this morning...i agree :^)

-pete




-- 
pete wright
www.nycbug.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


RE: Probably working too hard for this cron question

2011-06-13 Thread Gary Gatten
Yeah Pete, kinda need that huh.  Kurt, If that turns out to be the only issue, 
don't feel bad - I've forgotten it myself several times!  I'm sure many others 
have as well!

G


-Original Message-
From: owner-freebsd-questi...@freebsd.org 
[mailto:owner-freebsd-questi...@freebsd.org] On Behalf Of pete wright
Sent: Monday, June 13, 2011 3:25 PM
To: Kurt Buff
Cc: FreeBSD Questions
Subject: Re: Probably working too hard for this cron question

On Mon, Jun 13, 2011 at 12:52 PM, Kurt Buff  wrote:
> All,
>
> I've googled a bunch, read some freebsd.org docs, and just can't
> figure this out.
>
> I have a script that should read the current date into a variable,
> append the time/date stamp at the beginning of the file created with
> the date in the variable, do a bunch of cURL stuff, then append a
> time/date stamp at the end of the file.
>
> It works if I run it manually, but not from cron.
>
> Here are the batchfile and the cron entry:
>
> --begin script--
> dt=`/bin/date "+%Y-%m-%d"`
> /bin/date > /root/$dt-external1.txt
> /usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
> /bin/date >> /root/$dt-external1.txt
> --end script--
>
> --begin crontab--
> 15 12 * * *        /root/do-curl.sh
> --end crontab--
>
> I'm doing all of this as root, as you can see.
>
> The job launches - I can see an entry for cURL in top - but no file in /root.
>
> I've tried several variations on the first line of the script, but I'm
> getting nowhere, though I'm sure it's something stupidly simple that
> I'm missing.
>
> What am I missing?

#!/bin/sh ?

-pete



-- 
pete wright
www.nycbug.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"








"This email is intended to be reviewed by only the intended recipient
 and may contain information that is privileged and/or confidential.
 If you are not the intended recipient, you are hereby notified that
 any review, use, dissemination, disclosure or copying of this email
 and its attachments, if any, is strictly prohibited.  If you have
 received this email in error, please immediately notify the sender by
 return email and delete this email from your system."


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Probably working too hard for this cron question

2011-06-13 Thread pete wright
On Mon, Jun 13, 2011 at 12:52 PM, Kurt Buff  wrote:
> All,
>
> I've googled a bunch, read some freebsd.org docs, and just can't
> figure this out.
>
> I have a script that should read the current date into a variable,
> append the time/date stamp at the beginning of the file created with
> the date in the variable, do a bunch of cURL stuff, then append a
> time/date stamp at the end of the file.
>
> It works if I run it manually, but not from cron.
>
> Here are the batchfile and the cron entry:
>
> --begin script--
> dt=`/bin/date "+%Y-%m-%d"`
> /bin/date > /root/$dt-external1.txt
> /usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
> /bin/date >> /root/$dt-external1.txt
> --end script--
>
> --begin crontab--
> 15 12 * * *        /root/do-curl.sh
> --end crontab--
>
> I'm doing all of this as root, as you can see.
>
> The job launches - I can see an entry for cURL in top - but no file in /root.
>
> I've tried several variations on the first line of the script, but I'm
> getting nowhere, though I'm sure it's something stupidly simple that
> I'm missing.
>
> What am I missing?

#!/bin/sh ?

-pete



-- 
pete wright
www.nycbug.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Probably working too hard for this cron question

2011-06-13 Thread Kurt Buff
All,

I've googled a bunch, read some freebsd.org docs, and just can't
figure this out.

I have a script that should read the current date into a variable,
append the time/date stamp at the beginning of the file created with
the date in the variable, do a bunch of cURL stuff, then append a
time/date stamp at the end of the file.

It works if I run it manually, but not from cron.

Here are the batchfile and the cron entry:

--begin script--
dt=`/bin/date "+%Y-%m-%d"`
/bin/date > /root/$dt-external1.txt
/usr/local/bin/curl -K /root/urls.txt >> /root/$dt-external1.txt
/bin/date >> /root/$dt-external1.txt
--end script--

--begin crontab--
15 12 * * */root/do-curl.sh
--end crontab--

I'm doing all of this as root, as you can see.

The job launches - I can see an entry for cURL in top - but no file in /root.

I've tried several variations on the first line of the script, but I'm
getting nowhere, though I'm sure it's something stupidly simple that
I'm missing.

What am I missing?

Kurt
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: Cron Question

2008-09-06 Thread ElihuJ

Can anyone help me with this? Thank you again.
-- 
View this message in context: 
http://www.nabble.com/Cron-Question-tp19272656p19343758.html
Sent from the freebsd-questions mailing list archive at Nabble.com.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron Question

2008-09-03 Thread ElihuJ

Thank you for the help. I changed the script to run Weekly instead of Daily.
If it was starting while it was still running, this should fix it. I'll post
my progress, and thank you again.
-- 
View this message in context: 
http://www.nabble.com/Cron-Question-tp19272656p19287970.html
Sent from the freebsd-questions mailing list archive at Nabble.com.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron Question

2008-09-03 Thread Derek Ragona

At 10:45 AM 9/2/2008, ElihuJ wrote:


Hi all. I have a question about cron jobs that seem to be running to long or
with multiple copies of itself. For example, I have a backup script that I
run that seems to make multiple copies of itself. If I view the running
processes I see numerous instances of the same cron job. Is there something
I can do to limit this from happening? When it does, it drains my CPU and
some of my other processes are non responsive. Any help would be
appreciated. Thank you.
--
View this message in context: 
http://www.nabble.com/Cron-Question-tp19272656p19272656.html

Sent from the freebsd-questions mailing list archive at Nabble.com.


For longer running jobs I do a couple things.  I use a file to be sure only 
one instance is running, but I also add signal handling.  The following is 
written for ksh, but can be adapted to sh if needed:


=
#!/usr/local/bin/ksh
# uncomment the following line for debugging
#set -x


RUNNING_FILE=RUNNING_FILE=/tmp/my_cronjob_running
LOGFILE=LOGFILE=/tmp/my_cronjob.log
[EMAIL PROTECTED]
MAIL=/usr/bin/mail
TOUCH=/usr/bin/touch
RM=/bin/rm


# Print an epilog string and clear the RUNNING_FILE
function epilog {
  echo "We are all done scanning." >> $LOGFILE
$MAIL -s "MyCronjob Report" $SENDTO < $LOGFILE
if [ -f $RUNNING_FILE ]; then
$RM $RUNNING_FILE;
fi
}

function got_signal {
  echo "Got a signal" >> $LOGFILE
  epilog
  exit
}


# Here pointers to signal handling subroutines are set
trap got_signal TERM HUP INT QUIT

if [ -f $RUNNING_FILE ]; then
echo "mycronjob is already running"
else
$TOUCH $RUNNING_FILE
$RM $LOGFILE
$TOUCH $LOGFILE
#   add your job to be done here . . .
#
epilog
fi

=


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron Question

2008-09-02 Thread RW
On Tue, 2 Sep 2008 11:40:37 -0500
Dan Nelson <[EMAIL PROTECTED]> wrote:


> I use the lockfile command ( from the procmail port ) to ensure that
> recurring cron jobs don't overlap if one run takes too long. For
> example, to run mrtg on a 1-minute cycle but prevent multiple mrtgs
> from running if one run takes longer than 1 minute:
> 
> * * * * * /usr/local/bin/lockfile -r 1 -l 3600 /tmp/mrtg.LCK &&
> ( nice -19 /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg ;
> rm /tmp/mrtg.LCK )
> 
> The -l 3600 tells lockfile to remove any lockfiles over an hour old (
> if the machine was rebooted during an mrtg run for example )
> 
you could also handle stale lock-files, without installing procmail,
like this:

   LCK=/tmp/foo.LCK
   find $LCK -mtime +3600s -delete
   if ![ -f "$LCK" ] ; then
   touch "$LCK"
   [ -f "$LCK" ] && foo 
   rm "$LCK"
   fi

Presumably the lockfile command also eliminates the race between testing
for, and creating, the lock-file, but that's not really needed here.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron Question

2008-09-02 Thread Dan Nelson
In the last episode (Sep 02), Paul Schmehl said:
> --On September 2, 2008 6:03:51 PM +0200 Albert Shih wrote:
> >  Le 02/09/2008 à 08:45:52-0700, ElihuJ a écrit
> >> Hi all. I have a question about cron jobs that seem to be running
> >> to long or with multiple copies of itself. For example, I have a
> >> backup script that I run that seems to make multiple copies of
> >> itself. If I view the running processes I see numerous instances
> >> of the same cron job. Is there something I can do to limit this
> >> from happening? When it does, it drains my CPU and some of my
> >> other processes are non responsive. Any help would be appreciated.
> >> Thank you.
> >
> > That's not the to cron to do that.
> 
> Actually, it could be.  If the script is started by cron and is still
> running when the next job is scheduled, cron will start another
> process.  If they're both still running when the next job is
> scheduled, you'll have three processes running, etc., etc.

I use the lockfile command ( from the procmail port ) to ensure that
recurring cron jobs don't overlap if one run takes too long. For
example, to run mrtg on a 1-minute cycle but prevent multiple mrtgs
from running if one run takes longer than 1 minute:

* * * * * /usr/local/bin/lockfile -r 1 -l 3600 /tmp/mrtg.LCK && ( nice -19 
/usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg ; rm /tmp/mrtg.LCK )

The -l 3600 tells lockfile to remove any lockfiles over an hour old (
if the machine was rebooted during an mrtg run for example )

-- 
Dan Nelson
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron Question

2008-09-02 Thread Paul Schmehl
--On September 2, 2008 6:03:51 PM +0200 Albert Shih <[EMAIL PROTECTED]> 
wrote:



 Le 02/09/2008 à 08:45:52-0700, ElihuJ a écrit


Hi all. I have a question about cron jobs that seem to be running to
long or with multiple copies of itself. For example, I have a backup
script that I run that seems to make multiple copies of itself. If I
view the running processes I see numerous instances of the same cron
job. Is there something I can do to limit this from happening? When it
does, it drains my CPU and some of my other processes are non
responsive. Any help would be appreciated. Thank you.


That's not the to cron to do that.


Actually, it could be.  If the script is started by cron and is still 
running when the next job is scheduled, cron will start another process. 
If they're both still running when the next job is scheduled, you'll have 
three processes running, etc., etc.


The first thing I would do is run the script manually and see how long it 
takes to complete.  Then set your cron jobs up to run with enough time 
between them for the script to complete and exit before the next job 
starts.



Paul Schmehl, If it isn't already
obvious, my opinions are my own
and not those of my employer.
**
WARNING: Check the headers before replying


Re: Cron Question

2008-09-02 Thread Albert Shih
 Le 02/09/2008 à 08:45:52-0700, ElihuJ a écrit
> 
> Hi all. I have a question about cron jobs that seem to be running to long or
> with multiple copies of itself. For example, I have a backup script that I
> run that seems to make multiple copies of itself. If I view the running
> processes I see numerous instances of the same cron job. Is there something
> I can do to limit this from happening? When it does, it drains my CPU and
> some of my other processes are non responsive. Any help would be
> appreciated. Thank you.

That's not the to cron to do that. You must put in your script some flags.

For example if you using 

rsnapshot (in the ports)

he put a lock file in /var/run (or what's ever you want) and don't start if
the script find this file. When the script is end the file is erase.

Something like

if_the_lock_file_exit :

exit 1

else

touch lock_file

my_script

rm lock_file

fi.

Regards

-- 
Albert SHIH
SIO batiment 15
Observatoire de Paris Meudon
5 Place Jules Janssen
92195 Meudon Cedex
Heure local/Local time:
Mar 2 sep 2008 18:01:25 CEST
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Cron Question

2008-09-02 Thread ElihuJ

Hi all. I have a question about cron jobs that seem to be running to long or
with multiple copies of itself. For example, I have a backup script that I
run that seems to make multiple copies of itself. If I view the running
processes I see numerous instances of the same cron job. Is there something
I can do to limit this from happening? When it does, it drains my CPU and
some of my other processes are non responsive. Any help would be
appreciated. Thank you.
-- 
View this message in context: 
http://www.nabble.com/Cron-Question-tp19272656p19272656.html
Sent from the freebsd-questions mailing list archive at Nabble.com.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron question

2008-04-26 Thread John Almberg


On Apr 25, 2008, at 10:31 AM, John Almberg wrote:



...and invoking this wrapper from cron instead of trying to reset  
the shell and everything from within cron.  You can test things by  
doing an "su gs -c /bin/sh" from a root login and then trying to  
run your wrapper, which will give you a minimum environment closer  
to what cron executes under.




This was an interesting idea. I wrote a little ruby script to print  
out all set environment variable, then ran it under the simulated  
cron environment:


bin 520 $ su gs -c /bin/sh
$ ./env.rb
USER => gs
MAIL => /var/mail/gs
SHLVL => 2
HOME => /home/gs
_ => /bin/sh
BLOCKSIZE => K
TERM => xterm-color
SVN_EDITOR => vim
PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/ 
usr/local/bin:/usr/X11R6/bin:/home/gs/bin

SHELL => /usr/local/bin/bash
PWD => /home/gs/bin
FTP_PASSIVE_MODE => YES
EDITOR => vim
$

Then under the environment I used to run the script by hand:

[EMAIL PROTECTED] ~/bin]$ ./env.rb
TERM => xterm-color
SHELL => /usr/local/bin/bash
OLDPWD => /home/gs
SSH_TTY => /dev/ttyp0
USER => gs
SVN_EDITOR => vim
FTP_PASSIVE_MODE => YES
MAIL => /var/mail/identry
PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/ 
usr/local/bin:/usr/X11R6/bin:/home/identry/bin

BLOCKSIZE => K
PWD => /home/gs/bin
EDITOR => vim
HOME => /home/gs
SHLVL => 2
LOGNAME => identry
_ => ./env.rb

I don't see any difference that would explain this problem...

No mail is sent to either root or gs when the crontab runs.



Well, I finally figure this out. Printing out the environment  
variables when running the program by hand, and then when it ran as a  
crontab, turned out to be the key. The difference (not shown in the  
early experiment, above) was in the working directory. When I ran the  
script by hand, the working directory was /home/gs/bin, but when cron  
ran the script, the working directory was /home/gs. Unfortunately,  
this caused the script to die, because of a bug in the script itself.


Now that this script is running, the big question is, why are none of  
my login users getting any email? I'm sure that cron tried to send an  
email about the error that would have been helpful in debugging the  
problem, but it never arrived. But all the mailboxes in /var/mail are  
empty.


I am running qmail, which is also new for me... Like all djb stuff,  
it works great, but is stunningly difficult for my feeble brain to  
understand... I need to roll up my sleeves and try to understand  
what's happening to this mail.


Anyway, thanks for the help. It was definitely useful in putting me  
on the right track.


Brgds: John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron question

2008-04-25 Thread John Almberg


...and invoking this wrapper from cron instead of trying to reset  
the shell and everything from within cron.  You can test things by  
doing an "su gs -c /bin/sh" from a root login and then trying to  
run your wrapper, which will give you a minimum environment closer  
to what cron executes under.




This was an interesting idea. I wrote a little ruby script to print  
out all set environment variable, then ran it under the simulated  
cron environment:


bin 520 $ su gs -c /bin/sh
$ ./env.rb
USER => gs
MAIL => /var/mail/gs
SHLVL => 2
HOME => /home/gs
_ => /bin/sh
BLOCKSIZE => K
TERM => xterm-color
SVN_EDITOR => vim
PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ 
local/bin:/usr/X11R6/bin:/home/gs/bin

SHELL => /usr/local/bin/bash
PWD => /home/gs/bin
FTP_PASSIVE_MODE => YES
EDITOR => vim
$

Then under the environment I used to run the script by hand:

[EMAIL PROTECTED] ~/bin]$ ./env.rb
TERM => xterm-color
SHELL => /usr/local/bin/bash
OLDPWD => /home/gs
SSH_TTY => /dev/ttyp0
USER => gs
SVN_EDITOR => vim
FTP_PASSIVE_MODE => YES
MAIL => /var/mail/identry
PATH => /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ 
local/bin:/usr/X11R6/bin:/home/identry/bin

BLOCKSIZE => K
PWD => /home/gs/bin
EDITOR => vim
HOME => /home/gs
SHLVL => 2
LOGNAME => identry
_ => ./env.rb

I don't see any difference that would explain this problem...

No mail is sent to either root or gs when the crontab runs.

Someone asked what version of PHP...

~ 504 $ php --version
PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6 2008 18:26:54)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
~ 505 $

And if bash is really installed:

~ 505 $ bash --version
GNU bash, version 3.2.33(0)-release (amd64-portbld-freebsd6.3)
Copyright (C) 2007 Free Software Foundation, Inc.

I guess I will try using the shell script wrapper idea, to some more  
experiments in a more controlled environment.


-- John

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron question

2008-04-24 Thread Matt
On Thu, Apr 24, 2008 at 3:26 PM, John Almberg <[EMAIL PROTECTED]> wrote:
>  SHELL=/usr/local/bin/bash

Did you install bash from ports and does it run OK from outside of cron?

>
> PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/gs/bin
>  HOME=/home/gs
>  0 15 * * * /home/gs/bin/script.php >>/home/gs/log/script.log
>
>  I can see from the cron log that cron runs script.php at the appointed
> hour:
>
> Apr 24 15:00:03 on /usr/sbin/cron[72414]: (gs) CMD
> (/home/gs/bin/script.php >>/home/gs/log/script.log)

This entry in the cron log will still show up if the shell listed in
the crontab is not available.  However, as someone else already
mentioned, cron sends a mail when it goes to run and can't execute the
shell.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron question

2008-04-24 Thread Wojciech Puchar
0 15 * * * /usr/local/bin/php /home/gs/bin/script.php 

/home/gs/log/script.log


looks right. check mail - cron sends mail if something is wrong
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Cron question

2008-04-24 Thread Chuck Swiger

On Apr 24, 2008, at 1:26 PM, John Almberg wrote:
The trouble comes when I try to run this script with cron. I have  
something like this in the gs user crontab:


SHELL=/usr/local/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ 
local/bin:/usr/X11R6/bin:/home/gs/bin

HOME=/home/gs
0 15 * * * /home/gs/bin/script.php >>/home/gs/log/script.log

I can see from the cron log that cron runs script.php at the  
appointed hour:


	Apr 24 15:00:03 on /usr/sbin/cron[72414]: (gs) CMD (/home/gs/bin/ 
script.php >>/home/gs/log/script.log)


I believe that you are going to be better off writing a trivial  
wrapper like:


-

#! /usr/local/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ 
local/bin:/usr/X11R6/bin:/home/gs/bin

# ...other env variables you need...

touch /home/gs/log/script.log
/home/gs/bin/script.php >> /home/gs/log/script.log

-

...and invoking this wrapper from cron instead of trying to reset the  
shell and everything from within cron.  You can test things by doing  
an "su gs -c /bin/sh" from a root login and then trying to run your  
wrapper, which will give you a minimum environment closer to what cron  
executes under.


--
-Chuck

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Cron question

2008-04-24 Thread John Almberg
I have recently switched from Linux to FreeBSD for my web server.  
Absolutely love it, but am having one difficulty that is driving me  
bats...


I wouldn't think that cron would run differently on BSD than Linux,  
but it seemingly does. I have a user crontab that runs a PHP script  
once a day. This worked effortlessly on the old box.


If I am logged in as the user (gs), I can run the script without  
problem just by typing the command line ./script.php, or /full/path/ 
to/script.php


The trouble comes when I try to run this script with cron. I have  
something like this in the gs user crontab:


SHELL=/usr/local/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ 
local/bin:/usr/X11R6/bin:/home/gs/bin

HOME=/home/gs
0 15 * * * /home/gs/bin/script.php >>/home/gs/log/script.log

I can see from the cron log that cron runs script.php at the  
appointed hour:


	Apr 24 15:00:03 on /usr/sbin/cron[72414]: (gs) CMD (/home/gs/bin/ 
script.php >>/home/gs/log/script.log)


HOWEVER, absolutely nothing happens as a result. No error message in  
any /var/log file, and script.log is not even touched, even though  
the script is quite verbose and logs a bunch of stuff when it runs.


It is as if the script was never run. I have looked at this every  
which way, but it doesn't make any sense to me. There are other  
scripts in the same crontab that run without problem.


I have tried changing the crontab to:

0 15 * * * /usr/local/bin/php /home/gs/bin/script.php >>/home/gs/log/ 
script.log


But that has no effect.

So, the question is, how can a script that runs perfectly when  
executed by user gs from the command line, not work at all when run  
as user gs's crontab? Not even generate an error message or log  
entry? What is different in the user crontab runtime environment?


Any insight much appreciated.

Brgds: John

[EMAIL PROTECTED] ~]$ uname -a
FreeBSD on.identry.com 6.3-PRERELEASE FreeBSD 6.3-PRERELEASE #1: Mon  
Dec  3 09:46:53 EST 2007 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/ 
INET_ON  amd64


[EMAIL PROTECTED] ~]$ which php
/usr/local/bin/php


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2006-04-06 Thread RW
On Wednesday 05 April 2006 01:32, Kevin Kinsey wrote:

> And furthermore, you edited /etc/crontab or something similar
> instead of using crontab(1) to edit /var/cron/tabs/root.  Nitpicky,
> to be sure, but the cause of many a heartache:
>
> http://www.freebsd.org/doc/en/books/faq/admin.html#ROOT-NOT-FOUND-CRON-ERRO
>RS


The FAQ entry is about the mistake of using the crontab utility to install the 
system crontab (or a copy) as root's user crontab ( This is not helped by the 
fact that /etc/crontab refers to itself as "root's crontab" ). 

There is no such problem with simply editing  /etc/crontab - it's the more 
straightforward approach.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2006-04-05 Thread Giorgos Keramidas
On 2006-04-05 07:03, Marlon Martin <[EMAIL PROTECTED]> wrote:
> i created a simple shell script:
>
> filename: rn
>
> #!/bin/sh
> rndc dumpdb
>
> what it does, is just dump the hostname and IP addresses in /var/dump
> i set the time in 2 minutes but when i checked the logs, it doesnt work any
> idea what did i missed here?
>
> ==
>
> SHELL=/bin/sh
> PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
> HOME=/var/log
> #
> #minute   hourmdaymonth   wdaywho command
> #
> */5   *   *   *   *   root/usr/libexec/atrun
> #
> # Save some entropy so that /dev/random can re-seed on boot.
> */11  *   *   *   *   operator /usr/libexec/save-entropy
> #
> # Rotate log files every hour, if necessary.
> 0 *   *   *   *   rootnewsyslog
> #
> # Perform daily/weekly/monthly maintenance.
> 1 3   *   *   *   rootperiodic daily
> 154   *   *   6   rootperiodic weekly
> 305   1   *   *   rootperiodic monthly
> /2 *   *   *   * root   /home/ken/rn

You are missing a star '*' character before '/2' near the beginning of
the line immediatelly above.  Try this instead:

  */2   *   *   *   * root   /home/ken/rn

Then make sure /home/ken/rn is executable.

I'd also suggest moving your `rn' script in `/root/scripts/rn' and
making `root:wheel' its owner.  The crontab entries from `/etc/crontab'
are executed with root permissions, so giving the user `ken' control
over what runs is creating a backdoor for anyone who gets access to that
non-root user account.

- Giorgos

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2006-04-04 Thread Kevin Kinsey

Chuck Swiger wrote:


Marlon Martin wrote:
 


i created a simple shell script:

filename: rn

#!/bin/sh
rndc dumpdb

what it does, is just dump the hostname and IP addresses in /var/dump
i set the time in 2 minutes but when i checked the logs, it doesnt work any
idea what did i missed here?
   



You forgot to use the full path to rndc in your shell script.  You should not
assume that the $PATH cron passes you is going to have that command available.
 



And furthermore, you edited /etc/crontab or something similar
instead of using crontab(1) to edit /var/cron/tabs/root.  Nitpicky,
to be sure, but the cause of many a heartache:

http://www.freebsd.org/doc/en/books/faq/admin.html#ROOT-NOT-FOUND-CRON-ERRORS

... not sure if this one's affected you or not, but I'm wondering

Kevin Kinsey

--
Acid absorbs 47 times its own weight in excess Reality.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2006-04-04 Thread Chuck Swiger
Marlon Martin wrote:
> i created a simple shell script:
> 
> filename: rn
> 
> #!/bin/sh
> rndc dumpdb
> 
> what it does, is just dump the hostname and IP addresses in /var/dump
> i set the time in 2 minutes but when i checked the logs, it doesnt work any
> idea what did i missed here?

You forgot to use the full path to rndc in your shell script.  You should not
assume that the $PATH cron passes you is going to have that command available.

-- 
-Chuck

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


cron question

2006-04-04 Thread Marlon Martin
i created a simple shell script:

filename: rn

#!/bin/sh
rndc dumpdb

what it does, is just dump the hostname and IP addresses in /var/dump
i set the time in 2 minutes but when i checked the logs, it doesnt work any
idea what did i missed here?

==

SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hourmdaymonth   wdaywho command
#
*/5 *   *   *   *   root/usr/libexec/atrun
#
# Save some entropy so that /dev/random can re-seed on boot.
*/11*   *   *   *   operator /usr/libexec/save-entropy
#
# Rotate log files every hour, if necessary.
0   *   *   *   *   rootnewsyslog
#
# Perform daily/weekly/monthly maintenance.
1   3   *   *   *   rootperiodic daily
15  4   *   *   6   rootperiodic weekly
30  5   1   *   *   rootperiodic monthly
/2 *   *   *   * root   /home/ken/rn
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,310-5 *   *   *   rootadjkerntz -a
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2003-08-14 Thread Lowell Gilbert
Jim Pazarena <[EMAIL PROTECTED]> writes:

> I am trying to grep for a record from a crob job...
> the entry looks like this:
>  58  23 * * *   grep `date "+%Y-%m-%d "` /log/fylename | mail admin  
> 
> cron complains:
>   Syntax error:  EOF in backquote substitution
> 
> could someone enlighten me please?

You've got a quoting nightmare there.
Try wrapping it up in a shell script to be called from cron, 
and you won't have to worry what cron does to the tokens.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


cron question

2003-08-14 Thread Jim Pazarena
I am trying to grep for a record from a crob job...
the entry looks like this:
 58  23 * * *   grep `date "+%Y-%m-%d "` /log/fylename | mail admin  

cron complains:
  Syntax error:  EOF in backquote substitution

could someone enlighten me please?

-- 
Jim Pazarena  Box 550 mailto:[EMAIL PROTECTED]
  Queen Charlotte  BC http://www.qcislands.net/paz
  CANADA   V0T 1S0phone:250 559 
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: cron question

2003-03-15 Thread Giorgos Keramidas
On 2003-03-14 16:08, Kenzo <[EMAIL PROTECTED]> wrote:
> I'm trying to automatically create a report in cron and E-mailling it to my
> E-mail account.
>
> this is what I have.
>
> 0 1 0 0 0 root /usr/bin/perl /usr/local/bin/spamstat.pl /var/log/maillog.0 >
> /var/log/spam_report | uuencode spam_report spam_report | mail -s
> "spam_daily_report" [EMAIL PROTECTED]

What is 0 1 0 0 0 supposed to do?  I am inclined to think you have the
time information on that crontab line all wrong.

You're redirecting all output from spamstat.pl to the file
/var/log/spam_report.  Nothing goes down the pipe to uuencode.

> what I get is a blanc attachment.
> the spam_report file does get created in the /var/log dir with all the right
> stuff in it, so I don't get why it won't E-mail it.
> I have the same setup for another report and it works fine.
>
> I know this would probably work better if I created a script to do all this
> and have cron run the script, but I don't know how to write any scripts.

Just put the commands in /root/spam_report.sh and chmod 755 it.A
Try this script:

#!/bin/sh

/usr/bin/perl /usr/local/bin/spamstat.pl /var/log/maillog.0 | \
uuencode spam_report | \
mail -s "spam_daily_report" [EMAIL PROTECTED]

Then you can make this executable with:

# chmod u+x /root/spam_report.sh

and call it from /etc/crontab as:

0   1   *   *   *   root   /root/spam_report.sh

That should work fine :)

- Giorgos


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message


cron question

2003-03-14 Thread Kenzo
I'm trying to automatically create a report in cron and E-mailling it to my
E-mail account.

this is what I have.

0 1 0 0 0 root /usr/bin/perl /usr/local/bin/spamstat.pl /var/log/maillog.0 >
/var/log/spam_report | uuencode spam_report spam_report | mail -s
"spam_daily_report" [EMAIL PROTECTED]

what I get is a blanc attachment.
the spam_report file does get created in the /var/log dir with all the right
stuff in it, so I don't get why it won't E-mail it.
I have the same setup for another report and it works fine.

I know this would probably work better if I created a script to do all this
and have cron run the script, but I don't know how to write any scripts.

Thanks.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message