Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:17:00+00:00 2026-06-10T14:17:00+00:00

Possible Duplicate: Cron job on Ubuntu for php I am running and ubuntu server

  • 0

Possible Duplicate:
Cron job on Ubuntu for php

I am running and ubuntu server and wanted to run a php script every day. I have done some research and found that cron is the best way of doing this however, this is where i got stuck, a lot of the information on the internet about cron is very hard to follow and understand.

So i wanted to execute a simple php script once a day, the script i made for testing simply just deletes a record from a database, but the real script will do a lot more.

I tried setting up a task through plesk which is provided through my web host service but it didn’t seem to execute when i wanted it to, i used 1 for minutes, 22 for hours, * for day, * for week and * for month and thought this would execute every day at 22:01.

I have the directories on my server:
cron.hourly
cron.daily
cron.weekly
cron.monthly

I thought i could dump i file in there and it would execute for example every day, but i’m guessing i need to make a cron script to call a php script right?

If i were to go the way of putting a file in the cron.daily folder how would i go about it?

Also if there are any steps i need to take on the php side please let me know?

Thanks a lot for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:17:02+00:00Added an answer on June 10, 2026 at 2:17 pm

    There’s couple of ways to setup cron job. Assuming you got shell access you could do crontab -e from console and define job there, i.e. like this:

    1 22 * * * command
    

    which would trigger command (whatever it is) at 22:01 each day (not sure why you set minutes to 1 instead of 0 though). To launch PHP script from there you would either have to install php-cli, and then invoke it that way:

    1 22 * * * <path>/php -q script.php
    

    You can also call bash script here, to setup all the stuff like paths etc and then call your php script form bash – sometimes it is simpler to do that way instead of crafting way too long command line for cron. And it’s simpler to update it later. also, you could turn your php script into bash-runnable script by setting it execution bit (chmod a+x script.php) and adding shell’s shebang:

    #!/usr/bin/php -q
    <?php
       ...
    

    If your script got too many dependencies and you’d prefer to call it via web, you could use wget to mimic a browser. so your command would be:

    /usr/bin/wget --delete-after --quiet --spider <URL-TO-YOUR-SCRIPT>
    

    wget manual can be accessed by man wget or wget -h, or is on this website. Aternatively you may use HEAD tool from perl-www package – but it requires perl while wget is a standalone tool. If you use HTTPS with self signed certs, add --no-check-certificate to your invocation arguments. And you may also want to setup .htaccess and limit web access to your cron script to localhost/127.0.0.1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: running scheduled jobs (cron jobs) How to run a PHP file
Possible Duplicate: PHP list all files in directory ive got a cron job running
Possible Duplicate: cron : how to schedule to run first Sunday of every month
Possible Duplicate: PHP: running scheduled jobs (cron jobs) I need to update a database
Possible Duplicate: PHP: running scheduled jobs (cron jobs) How can I make my PHP
Possible Duplicate: How to call a JavaScript function from PHP? I have a php
Possible Duplicate: remove multiple whitespaces in php I have a stream of characters, a
Possible Duplicate: how to use ssh to run shell script on a remote machine?
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
Possible Duplicate: Find the smallest unused number in SQL Server I have this table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.