Results 1 to 5 of 5

Thread: cron job

  1. #1
    Join Date
    Sep 2008

    cron job

    Good morning everyone
    plz i want to know how to create a cron job using php function and also how to stop this cron from working using php...
    all that i need is to create a cron job using php and when the administrator press send -> the cron will be execute
    and when he press stop -> the cron will be deleted from cpanel

    note that: the administrator does not have an access to the cpanel and also if he has .. he can not deal with it.

    so can anyone have a function to creeate a cron job using php? and also stop it?

  2. #2
    Join Date
    Feb 2009
    Cron job is not the linx code

    those are Linux file which execute some script that can either php or any other lanugage

    There are two ways to make a cron job

    one is cpanel and other one is Linux shell.

    LG GC 900 Viewty 2 exposed

  3. #3
    Join Date
    Sep 2008
    Quote Originally Posted by End User View Post
    PHP Code:
    crontab_set ($min$hour$monthDay$monthNum$weekDay)

    $command "$min $hour $monthDay $monthNum $weekDay /usr/local/bin/php -f /home/egypthol/public_html/snd2.php";
    //echo $command;
    $cron_file "Feed_cron"
    // check for cron/Feed_cron file. If it doesn't exist create it.
        // you must create the file from the browser to associate the proper group
    if (file_exists($cron_file))
    // if it exists, write new command
    $open fopen($cron_file"w"); // This overwrites current line
    // this will reinstate your Cron job
    exec("crontab /home/egypthol/public_html/cron/Feed_cron") or die ("Error");

    // if it Doesn't exist, Create it then write command
    touch($cron_file); // create the file, Directory "cron" must be writeable
    chmod($cron_file0777); // make new file writeable
    $open fopen($cron_file"w");
    // start the cron job!
    exec("crontab /home/egypthol/public_html/cron/Feed_cron"
    or die (


    this is my code... and it makes the file Feed_cron and make inside it the commad

    but there is an error in the exec line coz when the page is loaded the die message ("error") appears.. so i found that the error is in the execute line

    could u plz help me in solving this problem

  4. #4
    Join Date
    Nov 2008
    Are you running this on a unix machine?

  5. #5
    Join Date
    Sep 2008
    plz take a look on these 2 links:

    http://www.egyptholidaytours.com/cron/cron.php --> this is the page that creates the cron job file and when wirting exec it shows the die error

    http://www.egyptholidaytours.com/cron/test.php --> shows the sever details

    plz i need help in solving this problem

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles