Astrometry not working with crontab

154 views
Skip to first unread message

Elif Şafak

unread,
Feb 19, 2020, 9:53:06 AM2/19/20
to astrometry
Hi

I use astrometry in python codes. When I run these python codes in terminal, astrometry works fine. But when I run python codes with crontab, astrometry doesn't work and no new files are created, and I don't get any errors.

What is the problem here?

Hans

unread,
Feb 19, 2020, 5:07:56 PM2/19/20
to Elif Şafak, astrometry
Hi Elif,
That is almost certainly an environment variable issue.

Can you share your exact crontab line(s) ? We can work from there.

-- Hans

Şafak

unread,
Feb 20, 2020, 5:19:01 PM2/20/20
to astrometry
Hi Hans,

Program running on the crontab like this:

    30 06 * * * python3 /mydir/program.py

And in python codes(program.py), astrometry runs like this:

    os.system("solve-field ........")

20 Şubat 2020 Perşembe 01:07:56 UTC+3 tarihinde Hans yazdı:

Dustin Lang

unread,
Feb 20, 2020, 6:46:16 PM2/20/20
to Şafak, astrometry
Hi,
When run in crontab, it is probably running as the 'root' user -- so none of your environment variables or anything from your ~/.bashrc or any other init files will get read -- so if you set PATH or PYTHONPATH or anything for your user, they will *not* be set for the root user.  Try logging in as root and try running your commands there.
cheers,
--dustin

--
You received this message because you are subscribed to the Google Groups "astrometry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/00297bc1-cdfd-42dc-aa9e-e8e6e2e4f739%40googlegroups.com.

Şafak

unread,
Feb 21, 2020, 3:01:18 AM2/21/20
to astrometry
Actually other processes in the program are working but only astrometry not working.

crontab line written in "sudo crontab -e "

Russell Valentine

unread,
Feb 21, 2020, 12:20:20 PM2/21/20
to astro...@googlegroups.com
It is probably the PATH variable.

In your crontab you can send the values of all your environment
variables to a file. You can do the same when you are logged in and
compare the two.

1 1 * * * /usr/bin/env > cron_env

Can change the hour and minute to run value so it runs soon

/usr/bin/env > login_env

diff cron_env login_env

https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it

Şafak

unread,
Feb 24, 2020, 6:03:58 PM2/24/20
to astrometry
I created a log and finally got the full error text. I hope it is enough for this solution:

solve-field.c:148:append_executable Error, couldn't find executable "astrometry-engine"

Also i checked crontab and it works as root. Problem is not user related.


21 Şubat 2020 Cuma 20:20:20 UTC+3 tarihinde Russell Valentine yazdı:

Dustin Lang

unread,
Feb 25, 2020, 6:57:47 AM2/25/20
to Şafak, astrometry
Where have you installed the astrometry code?

which solve-field
which astrometry-engine
?

astrometry-engine is the program that solve-field runs to actually do the solving.  Solve-field should look for astrometry-engine in the same directory, or search $PATH.  So you can set the PATH environment variable, but if it's in the same directory as solve-field, it should just work.

cheers,
--dustin



--
You received this message because you are subscribed to the Google Groups "astrometry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.

ŞAFAK

unread,
Mar 4, 2020, 3:01:44 PM3/4/20
to astrometry
Hi,
astrometry.net directory in my desktop. 

Thank you Dustin i figured out where the error originated, but should I move all the folders into the /usr/ folder?: include, bin, data, examples, etc, doc, share.

25 Şubat 2020 Salı 14:57:47 UTC+3 tarihinde Dustin Lang yazdı:
To unsubscribe from this group and stop receiving emails from it, send an email to astro...@googlegroups.com.

Dustin Lang

unread,
Mar 4, 2020, 3:10:47 PM3/4/20
to ŞAFAK, astrometry
You can do that via "make install INSTALL_DIR=/usr/local" , which is the normal way to install the code.


To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/7227f11e-5c89-4154-b21c-8827bdf22eec%40googlegroups.com.

ŞAFAK

unread,
Mar 4, 2020, 3:10:49 PM3/4/20
to astrometry
In addition, solve-field in the /usr/bin folder.

4 Mart 2020 Çarşamba 23:01:44 UTC+3 tarihinde ŞAFAK yazdı:

Jan-Benedict Glaw

unread,
Mar 4, 2020, 3:14:16 PM3/4/20
to ŞAFAK, astrometry
On Wed, 2020-03-04 12:01:44 -0800, ŞAFAK <elif...@ogr.iu.edu.tr> wrote:
> Hi,
> astrometry.net directory in my desktop.
>
> Thank you Dustin i figured out where the error originated, but should I
> move all the folders into the /usr/ folder?: *include, bin, data, examples,
> etc, doc, share.*

Please don't!

The point is that when called from cron, you don't have your usual
environment variables set.

This includes the $PATH variables which contains, colon-separated,
the pathes where programs are searched for. In crontabs, you can even
set these variables (see "man 5 crontab"). This is why you were
suggested to run the `env' command from your command line as well as
through cron to spot the differences. Most likely, you're good off by
setting PATH and any python related stuff (look for variables starting
with "PY".)

You should NOT copy or move your hand-compiled tools to /usr etc.
These directories are for regularly installes programs (those that
were installed through your package manager.) Either set $PATH
correct, or if you really would like to "install" your personal
binaries into the system, use /usr/local for locally-built stuff.

MfG, JBG

--
signature.asc

ŞAFAK

unread,
Mar 4, 2020, 4:04:24 PM3/4/20
to astrometry
i do that in my astrometry.net/bin directory:

export PATH=$PATH:"/home/ist60cal/astrometry.net/bin"
But crontab not found astrometry-engine


In which folder i should do INSTALL_DIR ?

4 Mart 2020 Çarşamba 23:14:16 UTC+3 tarihinde Jan-Benedict Glaw yazdı:

Jan-Benedict Glaw

unread,
Mar 4, 2020, 4:06:26 PM3/4/20
to ŞAFAK, astrometry
On Wed, 2020-03-04 13:04:24 -0800, ŞAFAK <elif...@ogr.iu.edu.tr> wrote:
> i do that in my astrometry.net/bin directory:
>
> export PATH=$PATH:"/home/ist60cal/astrometry.net/bin"
>
> But crontab not found astrometry-engine

So your crontab should probably look like this:

======================================
PATH=/bin:/usr/bin:/home/ist60cal/astrometry.net/bin

* * * * * .....
======================================

So it ships its own PATH!

MfG, JBG

--
signature.asc

Şafak

unread,
Mar 13, 2020, 7:25:20 PM3/13/20
to astrometry
"make install "command not working but it worked when i showed it together through solve-field in command. 

But now I'm getting a different error. The program is still running in the terminal but it gives this error even though it sees the path in crontab:

Command failed: an-fitstopnm -i /tmp/tmp.uncompressed.O8X2l6 > /tmp/tmp6GDnFp.pnm
augment-xylist.c:590:backtick Failed to run command: /home/astrometry.net/bin/image2pnm --infile /dir/2020_02_17__23_41_52__1600_600.fits.gz --uncompressed-outfile /tmp/tmp.uncompressed.O8X2l6 --outfile /tmp/tmp.ppm.f4zv0D --ppm --mydir /home/astrometry.net/bin/solve-field
 ioutils.c:567:run_command_get_outputs Command failed: return value 255
Reading input file 1 of 1: "/dir/2020_02_17__23_41_52__1600_900.fits.gz"...
sh: 1: an-fitstopnm: not found



4 Mart 2020 Çarşamba 23:10:47 UTC+3 tarihinde Dustin Lang yazdı:

Russell Valentine

unread,
Mar 13, 2020, 7:33:42 PM3/13/20
to astro...@googlegroups.com

Run:

which an-fitstopnm

Is that in the contabs path?

To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astrometry/fb2caf18-cbfe-4db6-bb04-b2bea1b3ab52%40googlegroups.com.

Şafak

unread,
Mar 13, 2020, 9:17:41 PM3/13/20
to astrometry
No, it's in "astrometry.net/bin"

Dustin Lang

unread,
Mar 14, 2020, 9:44:32 AM3/14/20
to Şafak, astrometry
This just should not be complicated.
"make install INSTALL_DIR=somewhere".
Add "somewhere" to the PATH variable before running solve-field.
That's it.

cheers,
--dustin


On Fri, Mar 13, 2020 at 9:17 PM Şafak <esafa...@gmail.com> wrote:
No, it's in "astrometry.net/bin"

--
You received this message because you are subscribed to the Google Groups "astrometry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astrometry+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages