Sriharsha Nb
Sriharsha Nb

Reputation: 33

Crontab job scheduling is not working

I have script which pull some data from remote database and write to a text file. This text file used to populate the local database.

If I run the individual script it is working as expected(Update the text file with records).

Its not working if added this script in crontab.

Crontab Expression:

0 * * * * /usr/bin/todb >>/usr/bin/mycommand.log 

Observations:the text file time stamp will change for the scheduled time but it is not getting updated with records.(O bytes) and it applies same for mycommand.log file also.

Bash Script:

file="/usr/bin/todb.txt"
if [ -f "$file" ]
then
rm /usr/bin/todb.txt 
fi
engineers_list=( abc 123 hjk )
for i in "${engineers_list[@]}"
do
    fing -s JKL  "( ( [Duplicate-on] >= 06/01/2014  ) and  [Engineer] = '$i' )" -w Identifier,DE-manager,Engineer -D ^ >> /usr/bin/todb.txt
done

Upvotes: 0

Views: 97

Answers (1)

Tomasz Jakub Rup
Tomasz Jakub Rup

Reputation: 10680

Output is in /usr/bin/todb.txt file, not in /usr/bin/mycommand.log.

/usr/bin/mycommand.log is touched (and timestamp is changed) bt all output is redirected to /usr/bin/mycommand.log.

Command

/usr/bin/todb >> /usr/bin/mycommand.log

redirects only stdout to mycommand.log. To redirect stdout and stderr try:

/usr/bin/todb >> /usr/bin/mycommand.log 2>&1

I guess Your script not find fing command.

Upvotes: 1

Related Questions