I wrote a simple shell script in centOS and executing this from a cron job. My script looks like below:
#!/bin/bash
export PATH=$PATH:$(pwd)
echo $PATH
echo $PATH| mail -s "PATH" me@gmail.com
And if I execute this script directly from terminal, it outputs below:
/sbin:/bin:/usr/sbin:/usr/bin:/vagrant
where /vagrant is the one I expected.
But if this is executed from cron job, it outputs (in my mail) like:
/usr/bin:/bin:/root
How I can set /vagrant properly when executed from a cron job?
UPDATE: I can set the /vagrant as PATH but it will work for me only. If I deploy my script to some other user, they have to make this directory. So I want to make the script like it will export the location from where it is running.
In my case , my script is running from /vagrant but the current directory is being exported as /root. This is the problem.
UPDATE: Sadly speaking, path was exported correctly but files from the /vagrant directory was reported to be not found.