0

This is how I display all Nginx logs at once aesthetically (with headings and spacing), in stdout, for comfortable debugging.

Input:

printf '\n\n General: \n\n'; nginx -t; printf '\n\n Access: \n\n'; tail /var/log/nginx/access.log; printf '\n\n Errors: \n\n'; tail /var/log/nginx/error.log

Output:

 General:

     ...

 Access:

     ...

 Errors:

     ...

As you can see, the command is quite long or "heavy".

Is there a shorter (formal?) way to achieve that?

0

I don't see any way to make the commands shorter, but you can wrap them in a bash function that you can execute later using the function name rather than pasting (or typing!) that command again.

For instance, you could put a function in your .bashrc like:

nginxlogs () {
    printf '\n\n General: \n\n'
    nginx -t
    printf '\n\n Access: \n\n'
    tail /var/log/nginx/access.log
    printf '\n\n Errors: \n\n'
    tail /var/log/nginx/error.log
}

Now when you run nginxlogs from your bash shell, everything will appear.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.