Posts Tagged crontab
Generate Crontab (Cron jobs) syntax/command using this simple tool
Posted by admin in Linux, Open Source on December 26th, 2010
Cron is a daemon used for scheduling tasks to be executed at a certain time. You can easily find great articles on Crontab or Cron daemon on the Internet. I found these articles very useful and easy to understand.
1. https://help.ubuntu.com/community/CronHowto
2. http://en.wikipedia.org/wiki/Cron
Actually, here I don’t want to explain how crontab work and how you can schedule tasks using crontab. I just want to discuss this tool I’ve created for generating crontab entries/syntax which you can copy and directly put in your crontab file.
In this tool there are five sections; minute, hour, day, month and weekday. You can select single or multiple values for each section from the list which you want to use in your crontab file.
You may want to run a script some number of times per time section. For example if you want to run crontab job in every 10 minutes (runs on minutes divisible by 10: 0, 10, 20, 30, etc.). In this case you can use “Every (x) minute” option and select 10 from drop down list. You can also get the correct output from “Minutes(s)” list but this option will generate less cumbersome output.
In “Command” text box you need to enter full command you want to execute in crontab. When you click Submit you will see this command with values for different section.
There should be single space between each section with the final section (command) can having one or more spaces in it.
Use lynx to run php file in crontab manager
Today, I was trying to set a php script file in crontab on Godaddy Virtual Dedicated server. Crontab executing that PHP script with warning. Actually, its not including the files which I am including using ‘require_once()‘ function. I have used the relative path for all the included files and its not possible to me to give absolute path for all files which are included. So, to solve this problem I have used lynx.
LYNX – lynx is the command line browser which is available on almost all the Linux versions. For more detail click here.
Instead, of using this command
/usr/bin/php /html/abc/public_html/cron.php
I have used this command
/usr/bin/lynx -source http://www.mywebsite.com/cron.php
in crontab manager. So, what lynx did is Its opens my cron.php files when this cron job execute.
-source Outputs HTML source instead of formatted text. To see all the available options of lunx click here.
If you don’t know the path of lynx on your server you can use ”whereis lynx” command using SSH. It will give you path of lynx directory on your server.
