1752675 Members
5642 Online
108789 Solutions
New Discussion юеВ

Re: shell script

 
shell script_1
Advisor

shell script

dear expert
usually i'm manual to run this CHECK.FILES command to check the file is got any problem or not .
Right now ,i wan to use crond job to control it. so i think i need to write a shell script to control it . by the way the path of file is /tmp/check.rx/chk.chs.files

may i know write the shell script ?
2 REPLIES 2
kemo
Trusted Contributor

Re: shell script

Hello shell

it is funny shell script is asking about shell script. :)
anyway .

As far as i understand that /tmp/check.rx/chk.chs.files is your executable which you use to check the files.

no need for a script to run this command. all what you need is to put this path "/tmp/check.rx/chk.chs.files" in your cron table and let it run it for you.
James R. Ferguson
Acclaimed Contributor

Re: shell script

Hi:

> usually i'm manual to run this CHECK.FILES command to check the file is got any problem or not . Right now ,i wan to use crond job to control it. so i think i need to write a shell script to control it . by the way the path of file is /tmp/check.rx/chk.chs.files

When running a script from 'cron' the most common failure (if any) is that 'cron' offers only a rudimentary environment. Essentially, you have your 'HOME', 'LOGNAME', 'SHELL' and most importantly a simple, default 'PATH'. Any variables you have defined and exported in your login shell are absent.

Your choices are several. Source (read) your '.profile' and then run your script:

# . ./profile;/tmp/check.rx/chk.chs.files

Note the dot ('.') followed by whitespace, followed by the '.profile'.

Another choice is to encode *all* of the variables you need in your script. A third choice is to declar the variables your script needs in a separate file which can be sourced (read) by any script (or profile) requiring them.

There are any number of posts in the forum with more details on the benefits and pitfalls of the above methods.

By the way, putting a production, permanent script in the '/tmp' directory is bad practice. It's liable to get removed during a reboot or vanquished by a system administrator who "knows better".

Regards!

...JRF...