welcome to Webune Support Forums, if you are interested in knowing how to test if cron jobs works, you can follow this simple tutorial we will show you step by step.
Webune Offers Linux Dedicated Servers!!!!!
1. first lets login to your server, i will be using ssh to login to my shell terminal. be sure to login as superuser (root)
NOTE: we recommend that you try this on a development machine, instead of in a production machine. if you need to do this for testing, we recommend you download a virtual appliance like VirtualBox by Sun or WMWare.
2. ok, now that you are logged in as root in your linux server, the first thing to check is if you have any cronjobs running. to list them, all you have to do is send this command:
crontab -l
this command just shows you a list of all the crons you have configured in your machine. if you dont have any, dont worry, its ok. if you do have any, get familiar with the syntax use, or just glace at the output to see how the command looks like
3. ok, now comes the fun part, for the purpose of this tutorial, lets say we want to create a file every minute in the /root/testing directory.
so lets create a testing directory in the /root directory for this tutorial, so send this command:
mkdir /root/testing/
now change directory to the newly created directory
cd /root/testing/
list all the files in the /root/testing/ directory (you should not see any files - command should come out empty)
ls /root/testing/
now lets create a script that will create our files every minute. I am using a RedHat/Fedora/CentOS distribution, so i am going to be using
nano as my text editor. if you have another favorite text editor you can use it, other popular text editors are VI and Pico - of if you are not familiar with either VI or Pico, lets stick with
nano - so, send this command:
nano cron_script
copy and paste the following instructions:
#/sbin/sh
# Creates a file with date as the name of the file
echo "Webune Web Hosting" > `date +%H-%M-%S`.txt
NOTE: the format is Hour-Minute-Seconds.txt
now make the script executable
chmod +x cron_script
now its time to add our script into our cron schedules so enter this command to edit the crontab file
crontab -e
NOTE: by default, the text editor is VI - so be sure you are familiar with VI for editing, this tutorial asumes you are not familiar with VI so these are the steps after you have send the crontab -e command:
Type on Keyboard: a
(you will see --INSERT-- at the bottom of the window - this means you are in editing mode)
Type on Keyboard: LEFT ARROW on keyboard
(this will put you at the beginning for the file - if not, then be sure you use the arrow keys on your keyboard to put the cursor at the beginning of the first line)
Type on Keyboard: ENTER
(this will create a new blank line at the beginning of the file)
Type on Keyboard: UP ARROW
(puts you back at the beginning of the first line)
enter this command on the first line:
*/5 * * * * /root/testing/cron_script
enter this on the last line of the file (if you have any cronjobs already)
*/5 * * * * /root/testing/cron_script
Type on Keyboard: Esc
(type the Esc key on your keyboard - this will get you out of edit mode)
Type on Keyboard: SHIFT + ;
(hit the Shift key and the color key on your keyboard to take you to the command mode in VI - you will see at the bottom of the windows a colon : )
Type on Keyboard: wq
(this tells VI to Write the changes and quit VI - so basically we are saving our work)
done