[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Linux Interview Questions



On Thu, Mar 15, 2007 at 06:26:25PM -0300, Jorge Peixoto de Morais Neto wrote:
> >
> >Ok so the min hour thing is wrong on the crontab. It should be something
> >like this:
> >
> >00 06 * * * [ `date -d tomorrow +%d` -eq '01' ] && /the/script
> >
> >for 6:00 AM on the last day of each month
> 
> 
> 
> I didn't know it was possible to put this kind of thing (the output of a
> command) in crontab. I searched for it in the man page and could not find it
> ( man 5 crontab on a Gentoo system). Interesting indeed.
> 

its not really "putting the output in the crontab". Its just testing
the command to see if it works. If it tests true then its will execute
the next command after the &&. otherwise, it will fail and the whole
command will then fail. 

when you have multiple commands on a line with && between them, it
executes them sequentially as long as none of them fail, IOW so long
as they return 0. the [ ... ] is the 'test' command and it tests the
statement inside the brackets and returns a 0 if the statement is
true. if its false (i.e. `date -d tomorrow +%d` is '02') then it will
return a 1 and the whole statement will fail. 

that's how I understand it.

A

Attachment: signature.asc
Description: Digital signature


Reply to: