background: My colleagues and I all login a AIX server with user "root", after login everyone loads their .profile/.kshrc/.netrc etc., then start their work, to execute their own shell scripts.
problem: when I crontab a script, it will fail because some cmds in it is only defined in my own environment. The failure remains even I add the sentences of source the .profile/.kshrc/.netrc in the script. It appears it just can not remember the former system setting.
question: How can I edit the script to get the task ran on my own environment?
A script run by cron should set its own PATH to assure it's starting from a known situation.
Make an inventory of all external commands used by the script, list the directories where they live, then add a line to the top of the script:
Etc...
In most case you want to include
/usr/bin
and/or/bin
-- for scripts run as root/usr/sbin
is another favourite.