Cron jobs

Cron jobs are perfect for executing a specific task or script at a scheduled time or different time periods.

Cron jobs can be run hourly, daily, weekly and monthly.

Cron configuration file is located:

/etc/crontab

This file should look like this:

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

Execute a job every X minutes

*/5 * * * * /path/to/script/script.sh

Use */10 for every 10 minutes, */15 for every 15 minutes… and so forth..

Execute a job every X hours

0 */5 * * * /path/to/script/script.sh

Use */2 for every 2 hours, */3 for every 3 minutes… and so forth..

Execute a job every Xth day of the week

Lets assume you want to execute a cron job every Wednesday at midnight:

0 0 * * 3 /path/to/script/script.sh

or

0 0 * * Wed /path/to/script/script.sh

You can use the corresponding number or the three letters for each weekday:

0=Sun
1=Mon
2=Tue
3=Wed
4=Thu
5=Fri
6=Sat

Please note that numbers starts with 0 for Monday, and not 1.

Execute a job every X months

You need to specify the what specific month or months you want to job to be executed. Like January and September:

0 0 1 1,9 * /path/to/script/script.sh

or

0 0 1 Jan,Sep * /path/to/script/script.sh

If you only want January and September, you should use a comma. If you want the job to be executed starting January and ending September, you need to use this format: 1-9.

Linux Server under DDOS Attack

To find out what IP is causing the DDOS, we can run the next command:

tail -n 10000 logfile.log | cut -f 1 -d ' ' | sort | uniq -c | sort -nr | more

The top IP addresses would be the ones to block.

Another way is looking at what resources are being requested:

cut -f 2 -d '"' logfile.log | cut -f 2 -d ' ' | sort | uniq -c | sort -nr | more

It’s probably you will see that they are trying to request a specific resource know as a common attack. For example, a common attack to wordpress would be:

GET /index.php? HTTP/1.0

Block an IP address range using the .htaccess file

I detected an attack to one (compromised) server running Apache and PHP. A fair amount of request were being made to a hacked resource. So one of the steps to avoid so many request was to block the IP range of the attacker(s). This was made via .htaccess in the site configured in apache:

Order Allow,Deny
Deny from XXX.XXX.XXX.0/24

That would stop the attack (for a few moment at least!)

Video Thumbnail in Dolphin – Fedora 23/24

After a long, long, long time, finally I can view my videos thumbnails in Dolphin.

I reported a Bug in RPMFusion Bugzilla back in Januay 2016 and earlier this morning I got the surpise that it was Resolved!

I want to thank Leigh Scott for getting this done. I’m really happy about it, since I have lots and lots of videos and being able to look at a small thumbnail is really helpful.

So, to get the package installed, all you need to do is:

$sudo dnf install ffmpegthumbs

After that, just need to enable it in Dolphin by going to Preferences > Configure Dolphin > General > Previews > Video files (ffmpegthumbs) and that’s it!

Thanks again for making this happen.

Fix Video Thumbnails in Dolphin 15.08.1 (KDE 5.17.0) in Fedora 23

When updating KDE in my Fedora 23, I lost the video previews in Dolphin. Even after installing ffmpegthumbs did not work.

So here is the solution:

sudo cp /usr/share/kde4/services/ffmpegthumbs.desktop /usr/share/kservices5/
sudo cp /usr/lib64/kde4/ffmpegthumbs.so /usr/lib64/qt5/plugins/

You need to have installed ffmpegthumbs for this to work, to install it:

sudo dnf install ffmpegthumbs

And you need to enable the video preview again in Dolphin.

zsh with oh-my-zsh

Zsh is a shell designed for interactive use.

To install it in Fedora:

yum install zsh

Once installed, you can run it with:

zsh

This will create a new file: ~/.zshrc with all the defaults configurations.

oh-my-zsh

oh-my-zsh it’s a community-driven framework for managing your zsh configuration. Includes a bunch of plugins and themes.

To install it:

curl -L http://install.ohmyz.sh | bash

To set zsh as the default shell:

chsh -s /bin/zsh

And restart your terminal.

And for sharing or synchronizing history between Zsh and Bash:

$ cat ~/.histfile >> ~/.bash_history
$ youreditor ~/.zshrc
# Here change your config to:
HISTFILE=~/.bash_history
$ rm ~/.histfile

For themes and plugins for oh-my-zsh:

Themes: https://github.com/robbyrussell/oh-my-zsh/tree/master/themes
Plugins: https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins

And that’s it.

Enjoy your zsh.