1834391 Members
1597 Online
110066 Solutions
New Discussion

absolute path name

 
khilari
Regular Advisor

absolute path name

Hi guys, well we have a cron job running where we are using ~directoryname but it is not working. Now, if i give it absolute path name like /home/directoryname will it work.

Any suggestions.
5 REPLIES 5
Pete Randall
Outstanding Contributor

Re: absolute path name

Yes - use always use absolute path names for cron jobs. When run through cron, jobs end up having a very sparse environment: variables are not set, the PATH is minimal. These things need to be taken into account when you write your script.

Check the man page for crontab to see the environment limitations.


Pete

Pete
Torsten.
Acclaimed Contributor

Re: absolute path name

from the crontab manpage:

"cron supplies a default environment for every shell, defining:

HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
...
"

If you like to have another environment, you have to create it.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Mel Burslan
Honored Contributor

Re: absolute path name

To the best that I know, tilde substitution does not work in a cron initiated session. You have to provide the full path to any file you desire to use.
________________________________
UNIX because I majored in cryptology...
DCE
Honored Contributor

Re: absolute path name


normally you need to use absolute paths in cron.

however, if you are performing a su comand from the the root crontab such as su - oracle -c "dbshut" then the oracle ID's environment gets loaded before the command is issued.

However, even in this case, you are better off using absolute paths in order to ensure the commands works as expected.

Victor Fridyev
Honored Contributor

Re: absolute path name

Hi,

The substitution ~something works, even in crontab if "something" is a username, it does not mean /home/something.

HTH
Entities are not to be multiplied beyond necessity - RTFM