Closed richardnicolas3 closed 5 years ago
Resolved.
I was able to resolve this myself.
In order for cron job to work properly you must edit squid-analyzer.
vi /usr/local/bin/squid-analyzer
Add line below to squid-analyzer in line 5 and save :wq - cron job will now work
use lib '/root/perl5/lib/perl5';
Then the cronjob worked just fine and it udpated the files so I can view on its webapge http://localhost/squidreport/
I'm updating it every minute with cron job below:
* * * * * /usr/local/bin/squid-analyzer > /tmp/squidanalyzer.log 2>&1
Sorry for the response delay I did not received the notification for the first post.
Editing squid-analyzer is a way to fix this issue and be sure that you will find the libraries even if the program is run manually but the right way could be tu use the -I
Perl option like this:
* * * * * perl -I /root/perl5/lib/perl5 /usr/local/bin/squid-analyzer > /tmp/squidanalyzer.log 2>&1
An other way is to set the following variable in your environment:
export PERL5LIB="/root/perl5/lib/perl5"
You can check that the path will be included by Perl using: perl -V
and look at paths in the @INC
array shown at end of the command output.
Sorry for the response delay I did not received the notification for the first post.
Editing squid-analyzer is a way to fix this issue and be sure that you will find the libraries even if the program is run manually but the right way could be tu use the
-I
Perl option like this:* * * * * perl -I /root/perl5/lib/perl5 /usr/local/bin/squid-analyzer > /tmp/squidanalyzer.log 2>&1
An other way is to set the following variable in your environment:
export PERL5LIB="/root/perl5/lib/perl5"
You can check that the path will be included by Perl using:
perl -V
and look at paths in the@INC
array shown at end of the command output.
Not a worry Darold thank you for replying. I'll try those lines in a test environment.
Do you see an issue with me running the cronjob every minute?
No there should not be any issue, squid-analyzer first look at other squid-analyzer running (I mean it check if the pid file already exists). If the previous run is not terminated it will simply die. The only thing is that you will have a warning in your cron log, if you see too many of them, increase the running interval, for example 2 or 3 minutes.
Perfect, thank you sir!
I am using the latest 6.6 on Centos 7. When I run "/usr/local/bin/squid-analyzer" from the shell it works fine and updates correctly. But it doesn't do anything from the cron job. The cron job itself runs but the log file has this error in it:
"Can't locate SquidAnalyzer.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/squid-analyzer line 6. BEGIN failed--compilation aborted at /usr/local/bin/squid-analyzer line 6.."
What can I do so the cron job can run properly?
edit:
I had made the cron job by vi /etc/cron.d/cronfiletorun
But now I deleted that and just made it under root running crontab -e to run every minute.
The cronjob file has this:
Then I got the same error and changed it by adding "perl -I" to the beginning. Now there is no error in the logfile but it is not updating anything.