How to create a cron job


#1

Today we will learn to setup a cron job.

The tutorial

Log in

Log in to your account at
https://www.000webhost.com/cpanel-login

Select your website

Click Manage Website on the website you want to add a cron job to.

Going to cron job

Go to Settings > Cron jobs

Creating the Cron job

Hit Create new cron job

Then, enter your script file name without /public_html/
If your script is in a directory (let’s say ‘scripts’), you should type scripts/<file name>
Then, set a time, and hit Create.

That’s it! We have created a cron job that runs every specified time, and executes the script :slight_smile:


Cannot create a cron job properly?
Cannot create a cron job properly?
#3

What type of files can I use? Only php files?


#4

Yes, PHP files are best :slight_smile:


#5

How can I trigger cronjob after specified time of some event ?


#6

Please explain further :slight_smile:


#7

Thanks for your attention,

After logging in to one page, there should be automatic log out after 10 minutes, even if user is doing something… It should give some warning at 9 minutes for logging out, then if user want to get logged in, he can abort that logout from his end.

I think for this functionality Cronjob is a good option, If not then can you suggest some other idea…

Thanks again.


#8

When the user logs in -> Set the current timestamp in a session.
Then each time the page reloads -> check if time bigger than 10 minutes.