Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #256096

Re: auto restarting in crontab

From Christoph Brinkhaus <c.brinkhaus@t-online.de>
Newsgroups linux.debian.user
Subject Re: auto restarting in crontab
Date 2023-03-16 12:30 +0100
Message-ID <G9TXY-cS35-5@gated-at.bofh.it> (permalink)
References <G9K8h-cLqL-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Am Thu, Mar 16, 2023 at 08:55:54AM +0800 schrieb coreyh@free.fr:
> Greetings,
> 
> My script for monitoring Node.js app as follows. I put it in crontab for
> auto-check and restart if failure.
> 
> #!/bin/bash
> 
> # scan the port
> nc -z 127.0.0.1 3000
> 
> if [ $? -eq 0 ];then
>   exit
> else
>   killall node
>   sleep 1
>   nohup serve -s  /home/myUsername/workspace/xxx-frontend/build &
> fi
> 
> 
> I can run the script by manual, but in crontab it won't work. that means,
> when node.js dies, it will not get restarted by this script automatically.
> 
The environments of login shells and crontab can be different. This
includes the path where to seek executables. Therefore it is good
practice not to write just the name of the executable as nc but the
name with the path as /usr/bin/nc. Here I took nc as an example.

Kind regards,
Christoph
-- 
Ist die Katze gesund
schmeckt sie dem Hund.

Back to linux.debian.user | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

auto restarting in crontab coreyh@free.fr - 2023-03-16 02:00 +0100
  Re: auto restarting in crontab Nicholas Geovanis <nickgeovanis@gmail.com> - 2023-03-16 02:10 +0100
    Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-16 02:40 +0100
      Re: auto restarting in crontab coreyh@free.fr - 2023-03-16 02:50 +0100
        Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-16 04:20 +0100
          Re: auto restarting in crontab coreyh@free.fr - 2023-03-16 07:30 +0100
        Re: auto restarting in crontab "pyh@ymail.ne.jp" <pyh@ymail.ne.jp> - 2023-03-16 05:00 +0100
          Re: auto restarting in crontab "pyh@ymail.ne.jp" <pyh@ymail.ne.jp> - 2023-03-16 05:10 +0100
            Re: auto restarting in crontab Jeremy Ardley <jeremy@ardley.org> - 2023-03-16 06:00 +0100
  Re: auto restarting in crontab Nicolas George <george@nsup.org> - 2023-03-16 09:00 +0100
    Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-16 12:10 +0100
      Re: auto restarting in crontab Nicolas George <george@nsup.org> - 2023-03-16 12:10 +0100
  Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-16 12:30 +0100
    Re: auto restarting in crontab Christoph Brinkhaus <c.brinkhaus@t-online.de> - 2023-03-16 14:00 +0100
      Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-16 14:10 +0100
        Re: auto restarting in crontab Nicolas George <george@nsup.org> - 2023-03-16 14:20 +0100
          Re: Re: auto restarting in crontab pyh@ymail.ne.jp - 2023-03-16 17:30 +0100
            Re: auto restarting in crontab Dan Ritter <dsr@randomstring.org> - 2023-03-16 18:40 +0100
              Re: auto restarting in crontab Jude DaShiell <jdashiel@panix.com> - 2023-03-16 19:00 +0100
              Re: auto restarting in crontab debian-user@howorth.org.uk - 2023-03-16 23:20 +0100
                Re: auto restarting in crontab Dan Ritter <dsr@randomstring.org> - 2023-03-17 00:10 +0100
                Re: auto restarting in crontab Jeffrey Walton <noloader@gmail.com> - 2023-03-17 00:40 +0100
                Re: auto restarting in crontab Nicolas George <george@nsup.org> - 2023-03-17 13:20 +0100
                Re: auto restarting in crontab debian-user@howorth.org.uk - 2023-03-17 13:20 +0100
                Re: auto restarting in crontab "pyh@ymail.ne.jp" <pyh@ymail.ne.jp> - 2023-03-17 01:10 +0100
                Re: auto restarting in crontab Greg Wooledge <greg@wooledge.org> - 2023-03-17 01:20 +0100
                Re: auto restarting in crontab debian-user@howorth.org.uk - 2023-03-17 13:30 +0100
  Re: auto restarting in crontab Christoph Brinkhaus <c.brinkhaus@t-online.de> - 2023-03-16 12:30 +0100

csiph-web