Jump to content
xisto Community
Sign in to follow this  
kc8yff

Cron Jobs What are cron jobs?

Recommended Posts

Cron jobs is a server side settings.You have to ask your server to give you permission to operate cron jobs.Cron jobs functions are easily available to non-windows servers.Most windows servers I had use before, do not support cron jobs.

Share this post


Link to post
Share on other sites

Yes...

Cron jobs are something like a task scheduler, you can tell the server to run a script every once in a while.

so your script would be somthing like

#!/bin/bash#uncomment one of the following.#to delete a set directoryrm /path/to/temp/directory/* -R#to delete a tempory directory given in parameter 1#rm $1 -R

i know you are a windows user, and thats a nix script, but this server is running on a nix system.
for a windows system, replace "#!/bin/bash" with "@echo off" and "rm" with "del"

Share this post


Link to post
Share on other sites

Yes...

so your script would be somthing like

 

#!/bin/bash#uncomment one of the following.#to delete a set directoryrm /path/to/temp/directory/* -R#to delete a tempory directory given in parameter 1#rm $1 -R

i know you are a windows user, and thats a nix script, but this server is running on a nix system.

for a windows system, replace "#!/bin/bash" with "@echo off"  and "rm" with "del"

<{POST_SNAPBACK}>


Slight improvision on the script to skip prompting in case it's enabled, since cronjobs can't interact:

#!/bin/bashrm -fR /path/to/temp/directory/*

Share this post


Link to post
Share on other sites

You can set up cron jobs from your cpanel. I think it's under the Advanced Tools section. From there, you can enter the script to be run, then set the schedule, like once every 15 minutes for every day of the year, or once every day, or once every month, so on.

Share this post


Link to post
Share on other sites

Can anyone just show an example of a script for both php and perl and guide us, how it is supposed to be entered in the Cron job thing in cpanel... I am also quite new to this thing.. ^_^

Share this post


Link to post
Share on other sites

here's a php code that will recursively delete all the files in a directory. To call this from a cron job, make the cron job run 'GET http://forums.xisto.com/no_longer_exists/ > /dev/null'. If you write a script that outputs some stuff (such as a script i wrote that synchronizes my site on Xisto with the backup site on another host), make the cron job run 'GET http://forums.xisto.com/no_longer_exists/ > /home/yourusername/public_html/results.htm'. Then, whenever it runs, it will save the results into http://forums.xisto.com/no_longer_exists/

<?phpfunction deldir($dir){ $current_dir = opendir($dir); while($entryname = readdir($current_dir)){    if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){       deldir("${dir}/${entryname}");    }elseif($entryname != "." and $entryname!=".."){       unlink("${dir}/${entryname}");    } } closedir($current_dir); rmdir(${dir});}deldir("/path/to/temp/directory/");echo "Deletion complete";?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.