简体   繁体   中英

crontab not executing a working shell script

I have a script of the following format:


#!/bin/bash

cd /abc/def/user1/test

export NIMBUS_ENV_FILE=/abc/def/user1/test/nimbus_env

main/vdnet -c yaml/config.yaml -t ABC. . .*


my script executes perfectly when run from the shell.I want to execute this script daily and so i have set a cron job for the same by editing crontab -e as :


PATH=/usr/bin:/usr/sbin:.

00 12 * * * /home/test.sh > /home/testCronLog.log 2>&1


Hoever, the cron job is run but it does not run the script as expected and gives following errors:

main/vdnet: line 2: readlink: command not found

dirname: missing operand

Try 'dirname --help' for more information.

main/vdnet: line 3: /../main/environment: No such file or directory

main/vdnet: line 8: /../scripts/nimbus/setup: No such file or directory

main/vdnet: line 14: /../main/vdNet.pl: No such file or directory


I do not get these errors when I manually execute the script and am not able to figure out whats wrong.The owner of the script is same as the crontab user. Please Help!!!

The issue is now resolved. I added the path to the script before running my command main/vdnet : export PATH=...

Thanks

when you use some command or something, or your script, its always better to give full path
so give full path of main/vdnet in your script

try changing the line which calls vdnet line in test.sh to:

main/vdnet -c /abc/def/user1/testyaml/config.yaml -t ABC...*

Your problem I think is that although test.sh runs perfectly from crontab, main/vdnet does not, and that is because the reference you have supplied it as the argument to the -c option needs the full path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM