Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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".