为什么我的ksh shell脚本意外死掉? [英] Why does my ksh shell script die unexpectedly?

查看:94
本文介绍了为什么我的ksh shell脚本意外死掉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个shell脚本,ssh到另一个盒子,在日志文件上运行cattail命令,并将输出重定向到本地盒子上不同目录下的文件。

名称shell脚本的内容是:desktop_SHM.ksh

I have a shell script that ssh over to another box, runs a cattail command on a log file, and redirects the output over a file on a different directory on the local box.
The name of the shell script is: desktop_SHM.ksh

展开 | 选择 | Wrap | 行号

推荐答案

你是SSH''ing从本地方框A进入远程方框B,将文件重定向到远程方框B中的不同位置?

为什么不在方框B上设置一个cron,每5分钟复制一次文件?


如果它''将该输出重定向回到方框A,为什么不通过利用框B上的syslog和A上的收集器将其发送出去?那将接近生存并且不依赖于cron ......
You''re SSH''ing from local box A into a remote box B to redirect a file to a different location in remote box B?

Why not just set a cron on box B to copy the file every 5 minutes?

If it''s redirecting that output back to box A, why not just send it over by utilizing syslog on box B and a collector on A? That would be close to live and not dependent on cron...


这基本上是正确的。

如果我在后台运行脚本,只要我不在命令提示符下更改目录或运行太多其他命令,它也能正常工作。似乎即使我在后台运行它,我也必须单独离开那个会话。


手动在终端中运行脚本肯定会很好地工作一整天。 />

/ var / log目录中没有任何内容。

我相信脚本在捕获正确数据1​​次后退出。我认为在cronjob运行我的脚本之后,它会运行一次,然后因为运行crobjob而死,要么死了要么开始其他工作,我的脚本就会死掉,因为我觉得它非常依赖运行它的会话。我不确定我是否正在解释这个问题,但如果您有任何疑问,请告诉我。


感谢您的帮助!
That is basically correct.
If i run the script in the background, it works fine also as long as I dont change directories or run too many other commands on the command prompt. It seems as though even if i am running it in the background, I have to leave that session alone.

Running the script in the terminal manually definitely works fine alllll day long.

There is nothing of interest in the /var/log directory.
I believe the script exits after cattailing over the correct data 1 time. I think after the cronjob runs my script, it runs once, and then dies because whatever is running the crobjob, either dies or starts some other job, and my script dies because I feel as though its very dependent on the session that runs it. I am not sure if i am explaining this right, but if you have any more questions, please let me know.

thanks for the help!!


对不起,我没有注意解决方案最初构建的方式并修改了我的响应。对解决方案有何想法?或者这是分配的,需要修改现在的内容吗?
Sorry, I wasn''t paying attention to the way the solution was architected originally and revised my response. Any thoughts to the solutions presented? Or was this assigned and needs to be a modification of what is there right now?


这篇关于为什么我的ksh shell脚本意外死掉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆