首页 \ 问答 \ 杀死Bash脚本中的所有无声进程(Kill All Silent Processes in Bash Script)

杀死Bash脚本中的所有无声进程(Kill All Silent Processes in Bash Script)

我在脚本中运行了一系列phantomjs的静默实例,当脚本结束时我想立刻杀掉它们。 但是要使脚本看起来不错,并且不要使用此消息使屏幕过载

./runTests.sh: line 74: 26002 Killed phantomjs Lib/loadtester/runTests.js $TEST_COUNT $CLIENT_LIMIT $ACTION $PROFILE $TEST_SERVER $TEST_INCREMENT $DEBUG_MODE > "/tmp/"$TEST_COUNT"_log.txt"

最好的方法是什么,我目前正在尝试:

(killall -9 phantomjs 2>&1) >/dev/null

我已经尝试了几乎所有我能想到的东西,包括killall中所有安静的选项


I run a series of silent instances of phantomjs in a script, when the script ends I want to kill them off, all at once. However to make the script look nice and not overload the screens with this message

./runTests.sh: line 74: 26002 Killed phantomjs Lib/loadtester/runTests.js $TEST_COUNT $CLIENT_LIMIT $ACTION $PROFILE $TEST_SERVER $TEST_INCREMENT $DEBUG_MODE > "/tmp/"$TEST_COUNT"_log.txt"

What is the best way to do so, I was currently trying:

(killall -9 phantomjs 2>&1) >/dev/null

And have tried pretty much everything I can think of including all quiet options in killall


原文:
更新时间:2022-05-11 11:05

最满意答案

你显示的代码工作得很好。 你绝对没有得到那条特定线路的错误信息。 错误是由其他地方引起的。

是的, %w创建一个字符串数组。 像你一样使用[]来创建正常的数组。

现在编辑您已经显示了真实的代码:

@config在您使用它的范围内nil ,所以当您执行@config[:strong_enabled]时会发生异常。

请注意,在类定义的内部,但在任何方法定义之外, @foo引用类对象的实例变量,而不是任何特定实例的实例变量(因为它引用了哪一个?还没有任何实例,当常量初始化)。


The code you showed works just fine. You're definitely not getting that error message for that particular line. The error is caused elsewhere.

And yes, %w creates an array of strings. To create normal arrays use [] like you did.

Edit now that you've shown the real code:

@config is nil in the scope where you use it, so you get an exception when you do @config[:strong_enabled].

Note that inside of a class definition but outside of any method definition @foo refers to the instance variable of the class object, not that of any particular instance (because which one would it refer to? There aren't even any instances yet, when the constant is initialized).

相关问答

更多
  • 好的,我找到了解决方案。 您可以使用attribute功能。 源代码如下所示: {% for job in attribute(scheduledJobs, constant('Namespace\\Class::CONSTANT')) %} http://twig.sensiolabs.org/doc/functions/attribute.html Okay, I found the solution. You can use the attribute function. The source co ...
  • 主版本的工作原理是因为你的编译器有一个扩展来允许变长数组。 即使数组和索引都是常量表达式(即错误的来源),数组访问也不能是C ++ 03中的常量表达式。 The main version works because your compiler has an extension to allow for variable length arrays. Array accesses cannot be constant expressions in C++03, even if the array and th ...
  • 一个数组不能是“常量” - 这甚至应该是什么意思? 在任何情况下,数组的大小已经是编译时常量,如果所有成员都是常量,那么你还想要什么? 你想排除什么样的突变对于const int[]是可能的? An array cannot be "constant" -- what is that even supposed to mean? The array size is already a compile-time constant in any case, and if all the members are ...
  • 您可以使用小型测试平台解答您的问题: module tb; reg [3:0] atop; initial begin $monitor("array_top=%b, array=%b", array_top, test_i.array); #1 atop = 4'b0000; #1 atop = 4'b0001; #1 atop = 4'b0010; #1 atop = 4'b0100; end wire [3:0] array_top = atop; test ...
  • 从PHP 5.6开始,类常量中允许使用数组。 请参阅有关正常运行的php代码的链接 。
  • 有没有办法声明一个常量“对”数据类型,以便包含的数组大小由常量数组定义确定? 不,遗憾的是这是不可能的。 您必须在方括号内声明数组的大小。 Is there a way to declare a constant "pair" data type so that the contained array sizes are determined by the constant array definition? No, sadly this is not possible. You have to decla ...
  • 编译器对数组的常量大小强制执行此规则,因为它在编译时分配所需的内存。 换句话说,在编译时必须知道计算数组大小所需的所有值。 在您的第一个示例中,情况并非如此,因此编译器会抱怨。 如果你真的需要动态大小的数组,你应该使用指针和new []运算符来分配数组。 您还需要记住使用delete []操作符将内存返回给系统并避免任何内存泄漏。 The compiler enforces this rule about a constant size of an array because it allocates th ...
  • 这个问题的重要特征是CUDA使用C ++编译模型,而dim3被视为一个类。 所以同时: dim3 foo = {1,1,1}; 在C ++ 11中是合法的,因为参数化构造函数初始化支持,这个: __constant__ dim3 foo = {1,1,1}; 不是,因为这意味着动态初始化常量内存对象,而CUDA执行模型不允许这样做。 如果常量内存方面对您很重要并且您想要dim3的便利,您可以执行以下操作: #include __constant__ int offsets[3*8]; ...
  • 你显示的代码工作得很好。 你绝对没有得到那条特定线路的错误信息。 错误是由其他地方引起的。 是的, %w创建一个字符串数组。 像你一样使用[]来创建正常的数组。 现在编辑您已经显示了真实的代码: @config在您使用它的范围内nil ,所以当您执行@config[:strong_enabled]时会发生异常。 请注意,在类定义的内部,但在任何方法定义之外, @foo引用类对象的实例变量,而不是任何特定实例的实例变量(因为它引用了哪一个?还没有任何实例,当常量初始化)。 The code you showe ...
  • 它不是有效的C89代码。 即使变量恰好是const ,也不能声明具有可变大小的数组。 如果你把它作为#define而不是const int它会工作。 但它在C99中有效。 GCC和其他编译器也将其作为C89模式的扩展。 It's not valid C89 code. You can't declare an array with variable size, even if the variable happens to be const. It would work if you had it as a ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)