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

Re: OT: Linux Interview Questions



[snip]
> >00 06 * * * [ `date -d tomorrow +%d` -eq '01' ] && /the/script
> >
> >for 6:00 AM on the last day of each month

[snip]
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.

Damn, so this is just a cheat, as the actual command is
[ `date -d tomorrow +%d` -eq '01' ] && /the/script
and it will be executed every day..


Regards,
Atis

(\.../)
(O.o)
(> <) This is Bunny. Copy Bunny into your signature to help him on his
way to world domination.



Reply to: