Get the most out of your Centmin Mod LEMP stack
Become a Member

Create a bash script

Discussion in 'System Administration' started by pamamolf, Jun 23, 2014.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    45,640
    10,356
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,071
    Local Time:
    10:02 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
  2. pamamolf

    pamamolf Premium Member Premium Member

    3,883
    381
    83
    May 31, 2014
    Ratings:
    +741
    Local Time:
    2:02 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    From the first check is too advance for me lol :)

    I will try with this:

    Code:
    exec "${@}" > >(tee logfile) 2>&1
    or this:

    Code:
    #!/bin/bash
    (
    # begin your commands
    .
    .
    .
    # end your commands
    ) 2>&1 | tee logfile.log
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    45,640
    10,356
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,071
    Local Time:
    10:02 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Both methods of I/O redirection work. I use a bit of both in Centmin Mod. The menu options use the 2nd you posted with piping to tee command.
     
  4. pamamolf

    pamamolf Premium Member Premium Member

    3,883
    381
    83
    May 31, 2014
    Ratings:
    +741
    Local Time:
    2:02 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    If i want to test the first command:

    Code:
    exec "${@}" > >(tee logfile) 2>&1
    Where i must place it in the script?

    At the top after #/bin/bash or at the end of the script?
     
  5. eva2000

    eva2000 Administrator Staff Member

    45,640
    10,356
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,071
    Local Time:
    10:02 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x