Cpanel Linux

Watch cpanel log files

From time to time you will need to examine logs looking to identify problems. An easy way to watch these files is with tail, grep, and zgrep. I will cover both and provide a few examples that I think will make it easier to quickly find issues on a Cpanel server without getting overly complicated.

Tail:  built to display the last few lines of files. Read the tail man page to find a full list of options.

Display file with (-f) follow then (-n)  the last 20 lines of the file. The second command displayed below will follow and display the three listed files, add more files by adding “-f -n /file” as many times as needed, or use a wildcard such as “*.com”. When using a wildcard care should be used as the number of sites you host fitting the wild card example could lead to a mess instead of usable info. Maybe this is a good time to set your window or scroll back to a few thousand lines plus. Also note when using tail and other programs that leave the file open for reading remove the follow option or your script will hang.

tail -f -n 20 /usr/local/apache/domlogs/
tail -f -n 20 /usr/local/apache/domlogs/ -f -n 20 /usr/local/apache/domlogs/ -f -n 20 /usr/local/apache/domlogs/


tail -f -n 20 /usr/local/apache/domlogs/*.com

Grep: Print lines matching a pattern

Grep: Provides an easy way to look into specific files or groups of files. Open file (-r) recursively looking for a specific pattern, only needed when looking into multiple files. Read the grep and zgrep man pages to find a full list of options.

Generic example:

grep "data-to-find" /file/location/

Cpanel example:

grep "data-to-find" /usr/local/apache/domlogs/

You can grep on multiple files at one.
Generic example

grep -r "data-to-find" /var/log/*

Cpanel example:

grep -r "data-to-find" /usr/local/apache/domlogs/*.com

zgrep: Allows you to look into archived log so no need to decompress before reading. The main different between grep and zgrep in this instance is that you do not need the (-r) option as zgrep recursively looks at multiple files if selected.

zgrep "data-to-find" /usr/local/apache/domlogs/

Assuming Cpanel is set to archive past logs.

zgrep "data-to-find" /home/username/logs/*.gz

Posting to social media

Posting to social media can be a great way to generate new leads and engage with previous customers, It can also turn your client base against you.

Here are a few Pointers to help in your journey.

Frequency, Quality, Content, and Credit.

The frequency of posts can and does have an effect on how a user perceives your page or business intent. Over posting can drive away users after the algorithms have decided if your new post is important enough to not need “boosting” at a cost to reach more users.  Throttling can also occur and at that point you want to put away the post button for a while. People or pages can follow your page they can also choose to see less if you over post for their liking (but they might just want to be noted as a friend and not receive new posts anyway). Your goal is to walk a fine line between posting just to post and providing a clear message.

Quality Rules all. Rule # 24 : Spelling and grammar. You don’t need to be an English major but you do need to use a spellchecker. When the comments on a post are talking about spelling errors instead of the intended message you have failed. Don’t worry learn from it. Even the big guys make errors, just don’t make it a habit. Rule # 78: Be descriptive! Create a picture with your idea. If the reader is unable to relate or understand your point you might miss an opportunity.

The content (links/pictures) posted should be linking back to you. If you are constantly posting to other sites you are driving traffic to them and loosing out on visitors that could be learning more about your business.

Also give credit where credit is due. All you need is a link at the bottom or your website post pointing back at the original. The temptation is to copy and paste the story, don’t fall into the trap and become a plagiarist. Even if your post is only two sentences that you wrote, that counts.