Operating System - HP-UX
1833150 Members
3499 Online
110051 Solutions
New Discussion

tty problem with Cron Job

 
Seah Hee Chuan
Occasional Advisor

tty problem with Cron Job

Hi, is it true that when I run a shell script command with cron job, cron job will not know what terminal it is on?
Can I set the terminal for my application, to a specific terminal eg /dev/pts/2 in a cron job.
Or should I do that in my shell script.But how?
Thank You
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: tty problem with Cron Job

Yes, this is true.

You can set the variable TERM in the script.

You can even if you wish pull your stty statements from /etc/profile or .profile and put them in the script.

Usually if the job needs a TERM variable set, thats enough.

Another thing to check in cron jobs: PATH

cron provides its jobs no environment whatsoever, they need to do that for themselves.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Nguyen Anh Tien
Honored Contributor

Re: tty problem with Cron Job

Hi, is it true that when I run a shell script command with cron job, cron job will not know what terminal it is on?
===
I have just tried writing small script to detect what tty crontab used.

#!/usr/sbin/sh
tty>/tmp/ttyid.log
and setting crontab.
and check
#cat /tmp/ttyid.log
not a tty.

It mean crontab does not use shell as tty.

--
Can I set the terminal for my application, to a specific terminal eg /dev/pts/2 in a cron job.
---
You can not set it. The Os will assign for you.



can you give me you shell script.
HP is simple
Seah Hee Chuan
Occasional Advisor

Re: tty problem with Cron Job

Thanks a lot guys.