GN Latest News

Information Regarding Cronjobs and VIM (Important)

Information Regarding Cronjobs and VIM (Important).
Essential command line configuration to be done next.
Some Web Based CP settings to do.
Change your Webalizer Web-Stats password.
Post Reply
Rob Swan
Site Admin
Posts: 73
Joined: Tue Oct 31, 2017 3:03 pm
Location: UK
Contact:

Information Regarding Cronjobs and VIM (Important)

Post by Rob Swan »

A cronjob is a schedules task you want your server to do, the crontab file is a list of those jobs.

We will be making a lot of cronjobs throughout the topics on this site.

It is ESSENTIAL that you never have any blank lines ANYWHERE in your crontab file, or the entire thing will not work. Throughout all the topics we use a file editor called VIM (sudo vi /folder/filename).

In this example there is blank line space at the end of the file, which can be very easy to miss.

Image

To make is easier, I have marked the problem with a red arrow.

In VIM, undefined lines are marked with a blue ~.

If we were going to fix this, we would use the arrow key to move the cursor down to the line in question.

Image

Then we would press the I key, the word INSERT would appear in the bottom left corner.

Image

We would then press the backspace delete key on the keyboard to remove the line (not the key with the word Delete on it)

Image

The line space has now been removed so we would then save the changes, so first press escape and the word INSERT will disappear.

Next press :, then w.

:w Will appear in the bottom left (this is the save changes command (write).

Image

Next, you would press enter, this has now saved the changes.

Next your would press : then q.

:q Will appear in the bottom left (this is the quit command)

Image

You would then press enter to close VIM.

If you where to mess any file up in vim, you can exit without saving the changes, to do this you must not use the write (:w) command, instead the command would be :q! (quit without saving changes).

Image

Incidentally, most other files can have blank line spaces in them.

You may have noticed some numbers in the corner of the VIM screenshots.

Image

The first number indicates the line number the second is the column number.

So, in our example our cursor in on line number 3 and we are 32 spaces from the left (column number).

It may look like we should be on line 4, (in the example above) but the first line is too long to fit on the page, so it wraps onto the next line.

However, it is still only one line.

If you were to make your PuTTY window wider, then you can see it is only one line more clearly.

Image

If we want to jump to the start of a file (VIM), we would use the command :0 (enter)Like this.

Image

Before entering a command that starts with :, you should press Escape, to clear the mode.

If we wanted to move to the last line in a file the command is :$ (press escape first, if you need to).

Finally if you want to clear the contents of a file, use the command :%d . The changes wont take effect until you use the write command (:w). Also (as above) you could use the :q! command to exit without saving the changes (if you have not already used the write command).
Post Reply