0

When I call my script from crontab the variables are not returning any values. Whereas when I execute it manually (command line) it works fine. I also observed only the $start_time and $end_time are not returning values whereas the $auto_job_name returns "mytext". Could you please help on this?

Contents of my script.

#!/bin/bash

auto_job_name="mytext"

start_time=`grep $auto_job_name job_status.txt`
end_time=`grep $auto_job_name job_status.txt`

echo $auto_job_name
echo $start_time
echo $end_time
samjerry
  • 47
  • 1
  • 6

1 Answers1

0

You might write the absolute path to your job_status.txt file, for example:

#!/bin/bash

auto_job_name="mytext"

start_time=`grep $auto_job_name /path/to/job_status.txt`
end_time=`grep $auto_job_name /path/to/job_status.txt`

echo $auto_job_name
echo $start_time
echo $end_time
Zumo de Vidrio
  • 1,748
  • 2
  • 10
  • 28