Teddy13, let me get some explanation here.
Ubuntu is the Linux distribution that you use. None of the commands you enter is exclusive to Ubuntu.
You ask questions on two separate questions. One of them: "How to write crontab". Another is "How to use vi, the default editor of the crontab command."
man crontab first to view the format of the entries in the file. Note that cron runs all executable files from the shell. You can run your "test.php" script if it is structured as a shell script, with the first line containing "shell magic" (for example, something like #!/usr/local/bin/php ).
Secondly, while vi is a powerful and well-loved text editor, it is not the easiest to use. I fully support any efforts you can make to learn how to use them, but until you feel comfortable, you might consider switching to "pico" or "ee" or "joe", which are much easier to learn, although they can do much less. You can install joe, for example, using the command: apt-get install joe run with administrator privileges. Then, to use joe to edit your crontab, add export VISUAL=/usr/bin/joe to the .bashrc in your home directory.
There is a lot of background information you might want to get. Read the lots. It's worth it.
UPDATE (per comment):
Here are the basic materials needed to edit your crontab.
crontab -e ... as you now know, this edits your crontab file with $ EDITOR or $ VISUAL, which is vi by default.- Inside vi, you are always in one of three modes. MOVEMENT mode allows you to move around the file using the arrows or H, J, K and L. You can delete lines with the help of "dd" or characters with "x". EDIT mode allows you to add or change text. In motion mode, use “i” or “a” or “o” to enter edit mode in different ways. Read the documents for more details. Thirdly, the COMMAND mode can be reached by pressing ":" in the driving mode. Here you can create various commands for saving, searching, bulk editing, etc.
- In move mode, you can save the file and exit using "ZZ". From edit mode, you can do this with the "wq" command (hence, ": wq" is mentioned elsewhere).
Alternatively, you can install the new crontab piping information into the crontab command. Note that this will destroy any existing crontab that you may have. Run this in your shell, updating the URL of your script as needed:
echo "0 20 * * * wget http://example.com/path/to/file.php" | crontab -
crontab -l will show you what the current crontab contains.
Hope this helps.
UPDATE # 2 (in the comments below):
$ tmpfile=/tmp/foo.$$ $ crontab -l > $tmpfile $ echo "30 6 * * * Mail -s wakeup pager@example.net <<< 'Time to wake up.'" >> $tmpfile $ crontab - < $tmpfile && rm $tmpfile
source share