How to ping a web site periodically
Answer:
1. Setup a cron job
crontab -e
2. Enter the job detail as following
1 * * * * /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
3. Fine tune the crontab configurations if needed.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to ping a web site periodically
Answer:
1. Setup a cron job
crontab -e
2. Enter the job detail as following
1 * * * * /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
3. Fine tune the crontab configurations if needed.
How to alter the priority of running processes
Answer:
The basic syntax is as the following
renice {priority} pid
Where priority range from -20 to 19 (lowest priority)
For example, to set the priority of pid 755 to -19, try
sudo renice 19 755
If you want to set by process name instead of pid, you can use
sudo renice 19 `pgrep apache2`
Where apache2 is the process name you want to set.
How to return the directory portion of a pathname
Answer:
Use the "dirname" command, e.g.
# dirname /usr/sbin/ufw
/usr/sbin
How to add line number to a file?
Answer:
The easiest way is to use the "sed" command
sed = test.txt | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
How to count the number of duplicated lines in a file
Answer:
Assume you have a file "test.txt"
a
b
b
c
c
c
You want to count the number of distinct rows, here is the command
# sort test.txt | uniq -c
1 a
2 b
3 c