The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Automated Cron Entry

Discussion in 'General Discussion' started by rhodesy, Dec 29, 2005.

  1. rhodesy

    rhodesy Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    305
    Likes Received:
    0
    Trophy Points:
    16
    Hey, Im looking to insert a cron job automatically from a php script - any ideas?

    The cpanel username and password are given.

    Thanks!
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Could just have the script append the new line to the cron file, then restart crond with the system command "/etc/rc.d/init.d/crond restart".
     
  3. rhodesy

    rhodesy Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    305
    Likes Received:
    0
    Trophy Points:
    16
    thats an idea - im noy too familuar with cpanels cron function - does each user have their own - im guessing they do - if so, where is it pls
     
  4. fikse

    fikse Well-Known Member

    Joined:
    May 10, 2003
    Messages:
    112
    Likes Received:
    0
    Trophy Points:
    16
    yes, each cpanel account has it's own cron settings.... cpanel > cron jobs

    if you want to run a php script as a cron job, do it like this:

    /usr/bin/php -f /home/userfolder/scrip.php
     
  5. rhodesy

    rhodesy Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    305
    Likes Received:
    0
    Trophy Points:
    16
    yes but i want to create the cron job without having to go into cpanel
     
  6. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    User cron jobs would be in the file at /var/spool/cron/username which doesn't exist until the user has a cronjob set. You just need to have your script add the properly formated line to that file and restart crond.
     
  7. rhodesy

    rhodesy Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    305
    Likes Received:
    0
    Trophy Points:
    16
    right - thankyou very much - il have a play around. The reason I want this is that its one less job for the user to have to do when installing a script of mine.
     
Loading...

Share This Page