Im trying to run script A which requires path /sbin.
I have a crontab entry to run script A every 10 minutes.
Script A is executed fine by cron, but because script A requires /sbin in its path it fails to run.
My situation is script A get overwritten from time to time so I can't modify script A to set path in there.
So my question is...
Is it possible to execute script A in cron by sourcing the path somehow without setting the path in the script.
I've tried exporting PATH and running the script but it seems like when the script executes, it is running with the default cron PATH.
Is there a cron default file which specifies this limited PATH? I would like to add the path there if it exists. /etc/crontab contains below
It already has /sbin specified, so then why does it only have /usr/bin:/bin in its path when executing?
I'm using RHEL 6.2.
Hope my question is clear.
Thanks.
Wilson.
Last edited by Corona688; 11-26-2012 at 11:32 AM..
I tried your suggestion and this is what I get. I have echo $PATH > tmp.file in the script A so I can check if the path has been sourced. It continues to print one with /sbin in its path which I think is being logged from export then once the script A executes it prints the PATH as being /usr/bin:/bin to the default again.
If the contents of the script change the PATH variable and you don't have any permanent control over the contents of the script you have two choices from what I can see:
1) Create symlinks in /usr/bin for the /usr/sbin executables the script needs. This can be a pain if there's a lot of them or if it's a long script and hard to guess what all it does, but it's a definite workaround to your issues with the script.
2) Explain to whoever is in charge of writing the script that it's broken. Ultimately there's only so much you can do if the script is breaking itself. Let them know that the change their script is making is causing it to have a bug on your platform and let them fix it however they need to. It's possible they wrote it for some other platform where all the executables it needs are either in /usr/bin or /bin.
I need help to grep file name with path from crontab
ex : 0 5 * * * /tmp/test.sh 2>/tmp/test.log
output : /tmp/test.sh
Please use code tags next time for your code and data. Thanks (6 Replies)
Hi!
We are on AIX 6.1 TL6
I am an Admin for a Content Management application that is hosted on an AIX machine and i am supposed to come up with a cronjob that runs every monday at 03:00 am.
The current schedule of that cron job is :
3 * * 1,3,5 /path/of/script.sh
But i do not know... (5 Replies)
i have a script running using variable defined in .profile
when i run that script manually its working
but when i run the same script through cron its giving path not found
I had defined path in .profile (3 Replies)
Hi Team,
Thank you for your time.
i have a situation where the user IDs of the applicatio users have been locked down to Read only.
Hence I am writing a script to invoke their old .profile every time they login.
My problem is : when i run . $userpath/.profile from within the ksh script... (9 Replies)
hi All, here is the problem: I'm not able to specify a PATH inside the user crontab file (/var/spool/cron/crontabs). The only syntax it accepts is the usual "* * * * * file" I'm not able to add PATH, or HOME, or MAILTO, or anything else. when I try to save the crontab, I have the error: ... (1 Reply)
Hi,
I have a script
#!/bin/ksh
#reading parameters.
. FileA
Echo ......
......
File A has all parameters.
FileA:
Infile=xyz.com
outfile=abc.com
#Userid file
. FileB
FileB: (2 Replies)
Hello,
I am quite new to Linux... I need to set some aliases and I can't get it to work. Can somebody tell me what's wrong?
I modified the .bashrc file in my home directory. I added:
alias pmv= '/home/vera/MGLTools-1.4.5/share/bin/pmv'
saved it and ran source .bashrc
The shell... (3 Replies)
Hi All,
I've searched through the forum for a solution to this problem, but I haven't found anything. I have 2 script files that are in different directories.
My first script, let's call it "/one/two/a.sh" looks like this:
#!/bin/sh
IN_DIR=`dirname $0`
CUR_DIR=`pwd`
cd $IN_DIR... (4 Replies)
hi All,
here the problem: I'm not able to specify a PATH inside the crontab file.
The only syntax it accepts is the usual "* * * * * file"
I'm not able to add PATH, or HOME, or MAILTO, or anything else.
when I try to save the crontab, I have the error:
"crontab: error on previous line;... (3 Replies)
Hello !
I want to make a script like that.
#!/bin/csh -f
setenv toto me
setenv titi you
setenv tata $1
in which tata is visible outside the script, after sourcing this script.
It seems that you can only do
source script and not
source script arg
How can I do that ?
... (4 Replies)