ack outputs nothing using crontab in linux.
In the crontab file (edited with sudo crontab -e
):
39 20 * * * /ext/test110.sh
And cat /ext/test110.sh
will show
#! /bin/sh /usr/bin/ack "localhost" /etc/hosts > /ext/1.t which ack > /ext/2.t
After cron, there are 1.t and 2.t in /ext
cat 2.t
will output /usr/bin/ack
;
However, nothing in 1.t
.
If I run ack "localhost" /etc/hosts > /ext/3.t
in bash (4.3.30) or sh directly,
it will output: 127.0.0.1 localhost
It seems ack cannot work with cron. where is the bug? Thank you.
uname -a
:
Linux xxx 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux
ack 2.14, Running under Perl 5.20.2 at /usr/bin/perl
Advertisement
Answer
/usr/bin/ack --nofilter "localhost" /etc/hosts > /ext/1.t
works.
Long Answer see https://github.com/beyondgrep/ack2/issues/649