-2
use strict;
use warnings;


################## Checking if regressions are running 

my $jobs;
my $output=`bjobs -w | tr -s " " | cut -d " " -f7 | tail -n +2 | sort -u | grep -i "_pv_"`;      ## Find out all the jobs running on cmd

print "$output is output\n";

When running the above code manually on a shell, it is running properly with no error. But when running it via crontab (12 23 * * * perl testScript.pl), it is throwing error. (Error: "bjobs command not found").

Why is it so? How can it be resolved?

Note: crontab has many scripts, so setting PATH variable at the top of crontab is challenging.

PPP
  • 329
  • 1
  • 9
  • Use the full path to `bjobs`, or add its directory to the PATH of your cron env (like you presumably do in your login script). – ikegami Aug 25 '23 at 07:51
  • @ikegami, where can i see environment file of crontab? Like, where env variables of crontab is set. And does crontab works in bash mode or csh mode? – PPP Aug 25 '23 at 09:24
  • @ikegami, when adding full path of bjobs, getting the following error: Aug 25 15:17:01 2023 7599 3 3.4.0 lsb_init: initenv_:fopen(/etc/lsf.conf) failed, No such file or directory. lsb_init: Failed in an LSF library call: Unable to open file lsf.conf – PPP Aug 25 '23 at 09:48
  • When running from cron/crontab it is not running in your user space, so you need to specifiy all the paths. – Rohit Gupta Aug 28 '23 at 13:40

0 Answers0