Posts

Showing posts with the label Linux Commands

How to running cron job every 5 minutes,seconds,hours,days

Image
How to running cron job every 5 minutes,seconds,hours,days. How to running a script a specific interval using cronjob in linux.  To execute a cronjob every 5 minutes */5 * * * * /home/huupv/script.sh To execute a cronjob every 5 hours 0 */5 * * * /home/huupv/script.sh How to running a job every 5 seconds $ cat every-5-seconds.sh #!/bin/bash while true do  /home/huupv/script.sh  sleep 5 done $ nohup ./every-5-seconds.sh & To execute a cronjob every 5th weekday 0 0 * * 5 /home/huupv/script.sh or 0 0 * * Fri /home/huupv/script.sh 0=Sun 1=Mon 2=Tue 3=Wed 4=Thu 5=Fri 6=Sat

Bash Scripting Made Simple: Practical Examples

Bash Scripting Made Simple: Explore practical examples to streamline your workflow and enhance your bash scripting skills effortlessly. List all IP addresses connected to Server Discovering all IP addresses connected to the server is essential for network monitoring and security. Utilize tools like netstat or ss commands to obtain this information efficiently. #!/bin/bash while true; do echo "CTRL+C TO BREAK" netstat -tnu | grep :22 | awk '{print $5}' | cut -f1 -d : | sort | uniq -c | sort -nr | head -n 8 sleep 15 clear done ########################################################################################### # site: huuphan.com # author: phan van huu # List all IP addresses connected to Server # For example: list ip address connected to server via ssh port 22 # awk '{print $5}' | cut -f1 -d : | sort | uniq -c | sort -nr | head -n 8 # awk '{print $5}': the display 5th field only # sort | uniq -c | sort -nr: Sort the list, group it

The usefull linux commands

Welcome to our guide on mastering essential command-line operations and system management tasks! In this blog post, we'll explore practical tips and tricks to streamline your workflow and boost productivity. Whether you're a beginner or an experienced user, these techniques will help you navigate the command line with ease. Join us as we dive into managing log files, executing commands efficiently, and optimizing your system administration skills for success. How to find and delete logs file MORE THAN 30 DAYS OLD # find /path/to/log/ -type f -name \*.log\* -mtime +30 -exec rm {} \; > /dev/null 2>&1 How to find and delete logs file   LESS THAN 30 DAYS OLD # find /path/to/log/ -type f -name \*.log\* -mtime -30 -exec rm {} \; > /dev/null 2>&1 How to one-liner that allows to create a directory and move into it at the same time. # mkdir test-dir && cd $_ How to display size of folder. #du -csbh /path/to/folder How to display output as a table # cat /etc/p

iptables examples

How to allow or denied on iptables firewall on centos. To configure iptables static file on centos.  You may reading link as below: Iptables how to How to reset password on centos 7 Bash script example *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT #### Mail port ### -A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 389 -j ACCEPT -s 10.10.9.0/24 -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT -A INPUT -m state --state NEW -