Date: Tue, 14 Jun 2011 00:02:58 +0200 From: Polytropon <freebsd@edvax.de> To: Kurt Buff <kurt.buff@gmail.com> Cc: FreeBSD Questions <questions@freebsd.org> Subject: Re: Probably working too hard for this cron question Message-ID: <20110614000258.c5cb84f3.freebsd@edvax.de> In-Reply-To: <BANLkTikJLpb-PQKWbuyX1F7GWzW1jMpirA@mail.gmail.com> References: <BANLkTimD4DaYtvDmiJ4=qaj3CNsKr=XHNQ@mail.gmail.com> <BANLkTinCFMqGBx0jkbRH-J03wNkQaPOo7Q@mail.gmail.com> <BANLkTikJLpb-PQKWbuyX1F7GWzW1jMpirA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 13 Jun 2011 14:44:29 -0700, Kurt Buff <kurt.buff@gmail.com> 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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110614000258.c5cb84f3.freebsd>