Category General

Executing PHP scripts over HTTP Using Cron Jobs

In programming there are a number of ways to execute on an idea and get a result, executing a php file on your web server is no different. Below I will provide examples of how to execute a php script or other type of script over http using configurable cron jobs.

Just about all webhosts also provide a method of adding cronjobs through their control panels including cpanel and plesk.

Method 1: Execute the script using php from the crontab

Just like how you call your shell script (As show in our crontab 15 examples article), use the php executable, and call the php script from your crontab as shown below.

To execute myscript.php every 1 hour do the following:

# crontab -e
00 * * * * /usr/local/bin/php /home/john/myscript.php

Method 2: Run the php script using URL from the crontab

Read More

Adding Aliases to your .bashrc


Ever wonder how you can make shortcuts for some of those long cumbersome Linux commands?  You can by making an alias for it.  What is an alias?  It is a shortcut, let me demonstrate.  Say you want to restart Gnome Network Manager.  To do that you would type the following in a terminal:

sudo /etc/init.d/networking restart

Now you could make an alias called
netre to save yourself some typing and this tutorial will show you how.

Remember this tutorial is for BASH and not SH, CSH, Korn, etc. and more specifically for use with Ubuntu.  I cannot guarantee that this will work with other Linux distributions.

The first thing you will need to do if open your .bashrc file located in your home directory.  To do this type the following in a terminal:

gedit ~/.bashrc

This will bring up the Gedi...

Read More

Show Plesk Admin Password

If you are using Plesk on Linux, have root access and need to recover the admin password, you can view it in plain text using the following command.




/usr/local/psa/bin/admin --show-password


This will pull the admin password from the database.  Simple enough, right?

Read More

Using df to Show Disk Space Usage in Linux

To display the disk space usage for your drives in Linux, you are able to use the df command.  By default, it will show the usage of all the mounted drives in 1k blocks.  If the POSIXLY_CORRECT environment variable is set though, it will show in 512 byte blocks by default.  Below shows the command run with no options.


chris@Desktop:~$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sdc1      575758492 126365356 420575064  24% /
udev             1538192        12   1538180   1% /dev
tmpfs             619612      1088    618524   1% /run
none                5120         0      5120   0% /run/lock
none             1549020       144   1548876   1% /run/shm

I...

Read More

Apache Error Codes

Below are a list of apache error codes. These can be helpful when checking for issues in the apache logs.

Read More

Install and run ClamAV

ClamAV is a popular malware scanner that can help to find malware on your accounts. You are able to find more information about that at the following link:

http://clamav.net

This software has many built in definitions that will find *most* of the malicious files under your accounts. It can find many shells, phishing sites and other malware. We won’t be able to cover all of the different options available in ClamAV in this article, but we will cover the parts that you will need to initially locate the malware so that it an be removed.

To install that, all you will need to do is run the following command.

If you are on a RedHat based OS, such as CentOS, you can install it with

yum install clamav

If you are using debian, you can use

apt-get install clamav

Once that is installed, you will want...

Read More

Create an ISO Image File from a CD or DVD

To create an exact image of a cd or dvd, you are able to use the dd command. If your disk is mounted at /mnt/disk, you can use this command to make an image file named disk.iso.

dd if=/mnt/disk of=/home/disk.iso

In that command, dd is the program that is used, if is the input file, and of is the output file. The result of that will be an exact copy of the disk in /home named disk.iso.

Read More

Create and Remove Directories

To create a directory in Linux, you will use the mkdir command with the name of the directory that your want to create.

mkdir foldername

To delete an empty directory, you can use the rmdir command with the path to the folder that you want to remove.

rmdir foldername

If the folder is not empty though, it will give you an error if you use the rmdir command. Instead, you will have to use the rm command to delete the folder and everything in it. So if you are totally sure you do not need anything in the folder, you can use this:

rm -rfv foldername

That command will remove everything in the folder, outputting what it’s doing as it’s doing it.

Read More

Using the du command

Using the du command will give you a list of the directories that are in your current directory, as well as the total size of all of the files and subdirectories included in that directory. I personally prefer to use the following, which will show the sizes in an easier to read format. It will show the files in GB or MB as well as KB, instead of all KB, which is what you will get with just du alone.

du -h

To show the size of a particular directory, you can specify that at the end of the command. It will output the size of the directories and subdirectories that are in that folder. The following will show the directories and subdirectories in the public_html folder and all of it’s subdirectories, in human readable format. The last value will be the total size.

du -h /home/user/public_ht...

Read More

Extract a tar and a tar.gz file

To extract a tar file named file.tar, you can use the following command.

root@server [~]#tar -xvf file.tar

In that, the x is the part that extracts, f defines the file and v gives verbose output, telling you what is being extracted.

To extract a file that is named file.tar.gz, you will use the z flag to ungzip it as well.

root@server [~]#tar -xzvf file.tar.gz

Read More