My first cron job

9. February 2019

The first thing I did was, I added a check in the header.php:

The first two lines inside of the if statement outputs a test.txt into the same folder as header.php with the time and date. (so I can check that the cron job is doing something)

After that it runs myFunction.

To make this code to run, you have to enter this address in your browser: https://www.example.com/?mycronjob, and that will trigger the content inside of the if statement.

So after that i logged into the server as a user and run this command:

And then I added the following to the file and saved it:

This means that it will ‘visit’ this site ones every hour (at 1200, 1300, 1400 and so on). The last part (/dev/null 2>&1) means that it wouldn’t send out any mail to the server admin.

Here are some ‘nice to know’ command you can use instead of ‘0 * * * *’:

Special stringMeaning
@rebootRun once, at startup.
@yearlyRun once a year, “0 0 1 1 *”.
@annually(same as @yearly)
@monthlyRun once a month, “0 0 1 * *”.
@weeklyRun once a week, “0 0 * * 0”.
@dailyRun once a day, “0 0 * * *”.
@midnight(same as @daily)
@hourlyRun once an hour, “0 * * * *”.
Adds a poodle to the terminal ?

1. October 2018

 

Zip a folder in Terminal

24. April 2018

Make sure you stand in your parent directory.

TAR.GZ:

ZIP (not always the server has zip library. Use Tar.gz):

Terminal command nice to know

20. April 2018

Logging of the server for some strange reason

20. April 2018

It is not every ISP that supports ‘keepalive’, if you are using a mobile connection for example, vill this happen.

If it happens with Ssh, you can run ‘top’ when you leave the terminal. Or you can: https://unix.stackexchange.com/questions/34004/how-does-tcp-keepalive-work-in-ssh

Make a script in Terminal

20. April 2018