nL cron script

Q&A's, tips, howto's
Locked
joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

nL cron script

Post by joejoe »

Hi,

I have a script I am trying to run from cron on Debian/Ubuntu.

Code: Select all

* * * * * joe /home/joe/winny/winny.lsp
The permissions of winny.lsp are 755.

Syslog looks like it is executing:

Code: Select all

Oct 26 01:49:01 jsfccfow CRON[6574]: (joe) CMD (joe /home/joe/winny/winny.lsp)
The winny.lsp script contains:

Code: Select all

(append-file "ltcbtc.txt" (println pairs (date (date-value) 0 "%y%m%d%H%M%S")))
The ltcbtc.txt file is already created and chmoded to 755.

I am not getting anything added to ltcbtc.txt file.

Anything I might be missing to get the nL script to run w cron?

Thank you! :-)

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: nL cron script

Post by ralph.ronnquist »

Code: Select all

* * * * * joe /home/joe/winny/winny.lsp
A line like the above would be fine in /etc/crontab or in /etc/cron.d/something-or-other, but for a user's crontab line (crontab -e), you'd skip the "user" field:

Code: Select all

* * * * * /home/joe/winny/winny.lsp
It's of course all nicely documented in

Code: Select all

$ man cron
hth

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: nL cron script

Post by joejoe »

Hi and thanks ralph,

I had tried that as well but it still doesn't append the file.

Any way to check for why it might not be working? Thanks!

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: nL cron script

Post by ralph.ronnquist »

A script file needs to tell which interpreter to use at it's first line, so it'd be like

Code: Select all

#!/usr/local/bin/newlisp
(append-file "ltcbtc.txt" (println pairs (date (date-value) 0 "%y%m%d%H%M%S")))
if you have installed newlisp at there.

Alternatively you make an embedded executable with the script; something like

Code: Select all

$ newlisp -x winny.lsp herbie ; chmod a+x herbie
and then use that in crontab.

Code: Select all

* * * * * /home/joe/winny/herbie
.

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: nL cron script

Post by joejoe »

ralph,

thanks for the help!

my nL script file has this already at top:

Code: Select all

#!/usr/bin/env newlisp
I can run it from the command line fine and it does it all.

I am almost ready to leave a nL process hanging just to make it done.?

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: nL cron script

Post by ralph.ronnquist »

println ? did you mean string ?

btw, cron scripts are run in $HOME so it would append to $HOME/ltcbtc.txt

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: nL cron script

Post by joejoe »

Working!

Moving the txt file and script to the home directory made cron all go!

You always share the best secrets ralph, thanks very much again for this!

Locked