0

I have wrote a script, and i am running xmonad and default terminal termite;just saying if it is important :), maybe there is a solution in xmonad.

, ((altMask, xK_x),
     spawn "termite --hold -e /home/emre/pipix.sh")

when i type in terminal

timeout 30 script.sh

it seems working. However when i type

termite --hold -e timeout 5 pipi.sh

I got this warning message

Try 'timeout --help' for more information.

What am i doing wrong or how can i make it work?

speedyy
  • 23
  • 3

3 Answers3

0

Often, if there are spaces in a command being passed as a single option on CLI, we often need to encase the command in quotation marks so that the program knows that the timeout 5 pipi.sh is a single command and not three separate input options.

termite --hold -e "timeout 5 pipi.sh"

Mind you, this is my guess based on common issues passing a line of code to a program on command line.

Jason K Lai
  • 534
  • 2
  • 8
  • After 5 seconds i got this warning (termite:4105): GLib-WARNING **: 11:55:27.131: GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). See the documentation of g_child_watch_source_new() for possible causes. – speedyy Dec 18 '19 at 08:56
0

i came across this post and i wanted to post it here.

https://www.tecmint.com/run-linux-command-with-time-limit-and-timeout/

Whoever needs to put a timelimit to command need to install the "timelimit" and use before their command

mine follows in xmonad.hs as this;

  , ((altMask, xK_c),
     spawn "timelimit -t25 termite --hold -e /home/emre/pipi.sh")
speedyy
  • 23
  • 3
-2

The following WAS tested and works as expected..

#!/bin/sh
temp=$$

(sleep 30; kill $temp; exit) &

echo "Hello. Testing timeout with ed."
# Your never ending code goes here instead. 
# Because ed is a new process you will have to kill it.
# killall ed would be replaced with the program name. killall XXX
(sleep 30; killall ed; exit) &

# run ed and put it in append mode and add a few characters.
# ed is never given the . and q! commands so it waits. 
ed

a

1234

echo "Should not get here"
# Should get a Terminated message and script exits in 30 seconds.
# And the process for  ed  is killed is in 30 seconds..

Ken

  • How does this answer the question? Also using `exit` in a subshell would just exit the subshell, which is what would happen anyway when the code within it is done. – Kusalananda Dec 18 '19 at 07:31
  • xterm -hold -e script.sh and it says kill: (3691) - no process \n kill: (3670) - no process... "no process" would be different i am translating – speedyy Dec 19 '19 at 09:27
  • (termite:3804): GLib-WARNING **: 12:25:33.365: GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). See the documentation of g_child_watch_source_new() for possible causes. – speedyy Dec 19 '19 at 09:41