1748203 Members
3285 Online
108759 Solutions
New Discussion юеВ

cron job

 
chakri
Occasional Contributor

cron job

Hi,

i have a shell scirpt which captures the output of a command using "script" command. i would like to run this shell script using cron job and this is not working as shell script is running a command using script command which i believe run the command in different shell.

is there a work around this problem? how could i run the shell script using cron?

Thanks,
Chakri
2 REPLIES 2
Oviwan
Honored Contributor

Re: cron job

hey

source your profile at the begin of your script, so that you have not the standard cron shell. e.g. you set the PATH env var in your profile etc..

to source your profile:
. /home/user/.profile

it would be helpful if you could poste more detail about the error of the script and also the script

regards
Wilfred Chau_1
Respected Contributor

Re: cron job

did you schedule the script to run with the -c flag and add an "exit" at the end of the script?

e.g. crontab
* * * * * script -c "test.sh" output.log

last line of test.sh should be "exit".