You are here

expect shell과 crontab 을 함께 하면 잘 안되네여..ㅠ.

리눅스 초짜입니다.
expect 쉘을 이용해서, 라우터에 들어가서 로긴하고,
시스템 점검 명령어를 자동으로 실행하는 쉘을 짜서,
그걸 crontab으로 돌리려고 합니다.

쉘은 다음과 같구요...

#!/usr/bin/expect

log_file /home/root/log/sample.log

spawn telnet 10.10.10.1
expect -re "User:"
send "userr"
sleep 1
expect -re "Password:"
send "passwordr"
sleep 1
send "show processes cpur"
sleep 1
send " r"
sleep 1
send " r"
sleep 1
send "exitr"
interact

요걸 crontab -e 해서
10 17 * * * /bin/sample

이렇게 만들었답니다.

직접 sample 화일을 실행시키면 아래와 같이 모든 정보가 잘 나옵니다.
# /bin/sample

(죄송..스크롤의 압박이...-.- )

그런데, crontab으로 돌리면, 위의 sample.log 에는 이 정보가 거의 잘려서 나오더라구여...
(잘린 내용은 더 밑에..-.- )


spawn telnet 10.10.10.1
Trying 10.10.10.1...
Connected to 10.10.10.1
Escape character is '^]'.

##############################################################

##############################################################

User:
Password:
Sample#show processes cpu
CPU utilization for five seconds: 5%/4%; one minute: 9%; five minutes: 10%
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
1 7812 4573606 1 0.00% 0.00% 0.00% 0 Load Meter
2 16 105 152 0.32% 0.02% 0.00% 2 Virtual Exec
3 25485772 2707306 9413 0.00% 0.09% 0.09% 0 Check heaps
4 0 1 0 0.00% 0.00% 0.00% 0 Chunk Manager
5 3520 11758 299 0.00% 0.00% 0.00% 0 Pool Manager
6 0 2 0 0.00% 0.00% 0.00% 0 Timers
7 0 2 0 0.00% 0.00% 0.00% 0 Serial Backgroun
8 0 1 0 0.00% 0.00% 0.00% 0 OIR Handler
9 0 1 0 0.00% 0.00% 0.00% 0 IPC Zone Manager
10 7452 22840514 0 0.00% 0.00% 0.00% 0 IPC Periodic Tim
11 4151600 52805332 78 0.00% 0.00% 0.00% 0 IPC Seat Manager
12 14085036 83620419 168 0.08% 0.07% 0.07% 0 ARP Input
13 25412 5669936 4 0.00% 0.00% 0.00% 0 HC Counter Timer
14 8 1809 4 0.00% 0.00% 0.00% 0 DDR Timers
15 8 3 2666 0.00% 0.00% 0.00% 0 Entity MIB API
16 0 1 0 0.00% 0.00% 0.00% 0 SERIAL A'detect
17 0 1 0 0.00% 0.00% 0.00% 0 Microcode Loader
18 0 4 0 0.00% 0.00% 0.00% 0 Critical Bkgnd
19 1562188 5131846 304 0.00% 0.00% 0.00% 0 Net Background
20 144156 4461307 32 0.00% 0.00% 0.00% 0 Logger
21 11996 22840504 0 0.00% 0.00% 0.00% 0 TTY Background
22 37032 22840514 1 0.00% 0.00% 0.00% 0 Per-Second Jobs
23 0 1 0 0.00% 0.00% 0.00% 0 Inode Table Dest
24 0 1 0 0.00% 0.00% 0.00% 0 Inode Table Refr
25 0 1 0 0.00% 0.00% 0.00% 0 IP Crashinfo Inp
26 0 1 0 0.00% 0.00% 0.00% 0 DSX3MIB ll handl
27 113196 22840513 4 0.00% 0.00% 0.00% 0 RSP Background
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
28 0 1 0 0.00% 0.00% 0.00% 0 Memory Scanner
29 4508 381139 11 0.00% 0.00% 0.00% 0 Slave Time
30 0 1 0 0.00% 0.00% 0.00% 0 Slave IPC OIR
31 0 1 0 0.00% 0.00% 0.00% 0 IP Flow Backgrou
32 36348 6473404 5 0.00% 0.00% 0.00% 0 Chassis Daemon
33 7008 381140 18 0.00% 0.00% 0.00% 0 RSP Chassis Back
34 4075020 8575176 475 0.00% 0.00% 0.00% 0 MIP Mailbox
35 4 101 39 0.00% 0.00% 0.00% 0 vcq_proc
36 0 1 0 0.00% 0.00% 0.00% 0 CT3 Mailbox
37 0 1 0 0.00% 0.00% 0.00% 0 CE3 Mailbox
38 0 1 0 0.00% 0.00% 0.00% 0 HAL Mailbox
39 0 1 0 0.00% 0.00% 0.00% 0 SRP Event Proc
40 11236092 55002784 204 0.00% 0.00% 0.00% 0 IPC CBus process
41 0 34 0 0.00% 0.00% 0.00% 0 TurboACL
42 55833208 285009404 195 0.00% 0.17% 0.25% 0 IP Input
44 0 1 0 0.00% 0.00% 0.00% 0 PPP IP Add Route
45 0 1 0 0.00% 0.00% 0.00% 0 X.25 Encaps Mana
46 0 1 0 0.00% 0.00% 0.00% 0 frr_tunnel
47 0 2 0 0.00% 0.00% 0.00% 0 SSCOP Input
48 0 2 0 0.00% 0.00% 0.00% 0 SSCOP Output
49 10524 381141 27 0.00% 0.00% 0.00% 0 SSCOP Timer
50 4653764 436791 10654 0.00% 0.02% 0.00% 0 IP Background
51 0 2 0 0.00% 0.00% 0.00% 0 ILMI Input
52 0 1 0 0.00% 0.00% 0.00% 0 SNMP Timers
53 0 2 0 0.00% 0.00% 0.00% 0 ILMI Request
54 0 2 0 0.00% 0.00% 0.00% 0 ILMI Response
55 0 1 0 0.00% 0.00% 0.00% 0 ILMI Timer Proce
56 4 2 2000 0.00% 0.00% 0.00% 0 ATM PVC Discover
57 0 2 0 0.00% 0.00% 0.00% 0 ATMSIG DRIVERAPI
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
58 152960 382582 399 0.00% 0.00% 0.00% 0 Adj Manager
59 181320 34656577 5 0.00% 0.00% 0.00% 0 CEF process
60 65788 113744822 0 0.00% 0.00% 0.00% 0 MDFS RP process
61 4416 1369100 3 0.00% 0.00% 0.00% 0 TCP Timer
62 134116 455846 294 0.00% 0.00% 0.00% 0 TCP Protocols
63 0 1 0 0.00% 0.00% 0.00% 0 Probe Input
64 0 1 0 0.00% 0.00% 0.00% 0 RARP Input
65 7802652 103520965 75 0.16% 0.07% 0.03% 0 IS-IS Adjacency
66 278324 381139 730 0.00% 0.00% 0.00% 0 IP Cache Ager
67 0 1 0 0.00% 0.00% 0.00% 0 PAD InCall
68 0 2 0 0.00% 0.00% 0.00% 0 X.25 Background
69 9668 381140 25 0.00% 0.00% 0.00% 0 TCP Intercept Ti
70 0 1 0 0.00% 0.00% 0.00% 0 Socket Timers
71 0 2 0 0.00% 0.00% 0.00% 0 TC-ATM Proc
72 0 2 0 0.00% 0.00% 0.00% 0 Tag Input
73 5584 7627454 0 0.00% 0.00% 0.00% 0 LSP Tunnel Head
74 0 1 0 0.00% 0.00% 0.00% 0 ISDN Timer
76 0 1 0 0.00% 0.00% 0.00% 0 SYSMGT Events
77 0 1 0 0.00% 0.00% 0.00% 0 ISDNMIB Backgrou
78 0 1 0 0.00% 0.00% 0.00% 0 CallMIB Backgrou
79 0 1 0 0.00% 0.00% 0.00% 0 SNMP ConfCopyPro
80 0 1 0 0.00% 0.00% 0.00% 0 Syslog Traps
81 16752 45622980 0 0.00% 0.00% 0.00% 0 cbus utilization
82 2834020 99008611 28 0.00% 0.00% 0.00% 0 Net Input
83 116480 4573606 25 0.00% 0.00% 0.00% 0 Compute load avg
84 6455928 381139 16938 0.00% 0.03% 0.00% 0 Per-minute Jobs
85 100339600 123982666 809 0.00% 0.39% 0.60% 0 IP SNMP
86 48 662 72 0.00% 0.00% 0.00% 0 SNMP Traps
87 10828 1205288 8 0.00% 0.00% 0.00% 0 CEF Scanner
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
88 0 2 0 0.00% 0.00% 0.00% 0 DSS Process
89 2899312 84994287 34 0.00% 0.01% 0.00% 0 CLNS Input
90 9764 3237522 3 0.00% 0.00% 0.00% 0 ES-IS Routing
91 52380776 72407506 723 0.08% 0.18% 0.21% 0 IS-IS Update
93 0 13 0 0.00% 0.00% 0.00% 0 TCP Listener
94 16672 23235107 0 0.00% 0.00% 0.00% 0 NTP
96 499032 421325962 1 0.00% 0.00% 0.00% 0 BGP Router
97 132360 1790702 73 0.00% 0.00% 0.00% 0 BGP I/O
98 430626552 4223227 101969 0.00% 1.98% 1.84% 0 BGP Scanner
Sample#
Sample#exit

spawn telnet 10.10.10.1
Trying 10.10.10.1...
Connected to 10.10.10.1
Escape character is '^]'.

##############################################################

##############################################################

User:
Password:
Sample#show processes cpu
CPU utilization for five seconds: 5%/4%; one minute: 9%; five minutes: 10%
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
1 7812 4573606 1 0.00% 0.00% 0.00% 0 Load Meter
2 16 105 152 0.32% 0.02% 0.00% 2 Virtual Exec
3 25485772 2707306 9413 0.00% 0.09% 0.09% 0 Check heaps
4 0 1 0 0.00% 0.00% 0.00% 0 Chunk Manager
5 3520 11758 299 0.00% 0.00%

으..대체 왜 이럴까요?
로그 화일 만들지 않고, 그냥 root로 메일 날아오게 해도, 똑같구여..
로그 용량 조절하는 명령어나 뭐 그런거 있나여?
crontab 돌리기만 안되는게 왜일까여? ㅠ.ㅠ

쉘에 문제가 있는건지, 아니면 crontab 설정을 뭔가 해 주는게 있는건지요?
그것도 아니면, stdout, stderr 이런거 설정을 다르게 해 줘야 할까요?

꼭 좀 알려주세여...
감사합니다.