473,411 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

crond

How do I create a process that will be called periodically to do some task?
This is not necessarily php but not sure where to ask.

Essentially I want to create either a php script or app(C++ would be nice)
to run once a day that will generate a set of images to be used for
captchas.

Any ideas or ideas where I can look for more info?

Thanks,
Jon
Jun 5 '07 #1
16 1870
you mentioned it in the subject of your post - use cron.

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.

#!/bin/sh

# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php

Jun 5 '07 #2
On Jun 5, 7:21 am, Lammi <Lorenz.Lammersd...@gmail.comwrote:
you mentioned it in the subject of your post - use cron.

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.

#!/bin/sh

# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php
if you can use cron cos you are on windows, use cronw instead. You can
also register your script as a service and start that every day (the
service could self-stop after its work is done) then you could use a
line such as
"service name" start
in cron
I dont see a point to registering as a service, but I mention it just
for fun!

Jun 5 '07 #3
shimmyshack wrote:
On Jun 5, 7:21 am, Lammi <Lorenz.Lammersd...@gmail.comwrote:
>you mentioned it in the subject of your post - use cron.

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.

#!/bin/sh

# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php

if you can use cron cos you are on windows, use cronw instead. You can
also register your script as a service and start that every day (the
service could self-stop after its work is done) then you could use a
line such as
"service name" start
in cron
I dont see a point to registering as a service, but I mention it just
for fun!
Or easier yet - just set up a scheduled task in the control panel.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 5 '07 #4

"shimmyshack" <ma********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
On Jun 5, 7:21 am, Lammi <Lorenz.Lammersd...@gmail.comwrote:
>you mentioned it in the subject of your post - use cron.

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.

#!/bin/sh

# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php

if you can use cron cos you are on windows, use cronw instead. You can
also register your script as a service and start that every day (the
service could self-stop after its work is done) then you could use a
line such as
"service name" start
in cron
I dont see a point to registering as a service, but I mention it just
for fun!
Actually guys, I have no idea how to run a script or anything on the web
host's server but I assume they have this ability? (to schedule maintenance)

I think its a linux platform so I image they have crond or something like
that. There web site forum was down last time I checked so I haven't found
out whats really going on.

Thanks,
Jon
Jun 5 '07 #5
Jon Slaughter wrote:
"shimmyshack" <ma********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
>On Jun 5, 7:21 am, Lammi <Lorenz.Lammersd...@gmail.comwrote:
>>you mentioned it in the subject of your post - use cron.

http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.

#!/bin/sh

# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php
if you can use cron cos you are on windows, use cronw instead. You can
also register your script as a service and start that every day (the
service could self-stop after its work is done) then you could use a
line such as
"service name" start
in cron
I dont see a point to registering as a service, but I mention it just
for fun!

Actually guys, I have no idea how to run a script or anything on the web
host's server but I assume they have this ability? (to schedule maintenance)

I think its a linux platform so I image they have crond or something like
that. There web site forum was down last time I checked so I haven't found
out whats really going on.

Thanks,
Jon

Jon,

You may or may not have the ability. It depends on the permissions the
host gave you. Some allow cron jobs, some don't.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 5 '07 #6
>
You may or may not have the ability. It depends on the permissions the
host gave you. Some allow cron jobs, some don't.
Now is that really the only way to schedule stuff in a linux enviroment? I
mentione dthe crond int eh subject cause thats all I know about.

What I'm trying to get at, is it going to be impossible to schedule stuff if
the host doesn't have it setup to do that? Obviously it can be impossible
but here I mean in general for most web hosts is it a common thing to allow
or deny?

Also is there any way to check for schelduling abilities? I have no shell in
the web host I think... just ftp and http.

oh, wait, I think I do have schelduling abilities... in the control panel
stuff for the site. I'll have to go check and see as I remember seeing that.

Thanks,
Jon
Jun 5 '07 #7
oh, wait, I think I do have schelduling abilities... in the control panel
stuff for the site. I'll have to go check and see as I remember seeing
that.
Yep, I guess they do. Has a way to add cron jobs and just have to give it
the script name.

I assume this is bash stuff? (I haven't done any unix scripting in a very
long time and very little but I assume the other posts give the script that
will work here). I just remember there being several types

Ultimately though I'd like to create a C++ app that will generate the
captchas since it will probably be optimized. I'm not sure how the web hosts
deal with time sharing but I don't want to take to much time. Ultimately I'd
like to generate the captchas in real time when they are needed and apply
random transformations to them instead of pre generating but I think this
might be to slow. (not sure how long it will take to generate one)

I guess I can do some tests and find out though after I get the thing
working.

Thanks,
Jon
Jun 5 '07 #8
Rik
On Tue, 05 Jun 2007 18:14:15 +0200, Jon Slaughter
<Jo***********@Hotmail.comwrote:
>>
You may or may not have the ability. It depends on the permissions the
host gave you. Some allow cron jobs, some don't.

Now is that really the only way to schedule stuff in a linux enviroment?
I
mentione dthe crond int eh subject cause thats all I know about.

What I'm trying to get at, is it going to be impossible to schedule
stuff if
the host doesn't have it setup to do that? Obviously it can be impossible
but here I mean in general for most web hosts is it a common thing to
allow
or deny?

Also is there any way to check for schelduling abilities? I have no
shell in
the web host I think... just ftp and http.

oh, wait, I think I do have schelduling abilities... in the control panel
stuff for the site. I'll have to go check and see as I remember seeing
that.
That's where most hosters that allow it put it indeed. Gives them somewhat
more control then allowing it by shell.

If they don't offer it, you could always put up a page that does the work,
and call that from a computer that does have scheduling enabled. (Possibly
with some safety checks.)

--
Rik Wasmus
Jun 5 '07 #9
Jon Slaughter wrote:
I assume this is bash stuff? (I haven't done any unix scripting in a very
long time and very little but I assume the other posts give the script that
will work here). I just remember there being several types
Cron doesn't specifically require bash scripting.

Cron can be used to launch any executable file at a frequency of up to
once per minute. (Or as infrequent as once every 28 years[1] if need be,
but that seems a bit excessive -- if something needs scheduling that
infrequently, you're better off running it manually.)

These executables could be bash scripts, tcsh scripts, Perl scripts,
compiled C code, or raw machine code written in a hex editor if you
like -- anything that you could run from the command line can run from
cron.

That said, most people do seem to use either Perl or some form of shell
scripting for cron jobs.

____
1. Cron users may not believe this, as cron tabs only allow you to specify
minutes, hours, days and months, so it's not clear how to schedule a job
to happen once every 28 years. Technically, you can't, but you can
approximate it by scheduling the job to happen on Sunday 29th February, a
date which only occurs (on average) every 28 years, because of leap years
and the fact that there isn't an integer number of weeks in each year.
Under normal usage, the longest time between cron jobs is 1 year.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 102 days, 1:16.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Jun 5 '07 #10
Jon Slaughter wrote:
Now is that really the only way to schedule stuff in a linux enviroment?
Cron? No -- there is also "at", but that's more suited towards scheduling a
one-off event in the future.

Or you could write a system service that sleeps for X seconds, wakes up,
does its job and then sleeps again.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 102 days, 1:25.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
Jun 5 '07 #11
On Jun 5, 6:43 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
Jon Slaughter wrote:
Now is that really the only way to schedule stuff in a linux enviroment?

Cron? No -- there is also "at", but that's more suited towards scheduling a
one-off event in the future.

Or you could write a system service that sleeps for X seconds, wakes up,
does its job and then sleeps again.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 102 days, 1:25.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/
you could also write a php script that is behind some protection,
which a cron on a machine you do have access to executes.
http://server.com/doit/job63.php?log=secure_email or whatever.

Jun 5 '07 #12

"Toby A Inkster" <us**********@tobyinkster.co.ukwrote in message
news:un************@ophelia.g5n.co.uk...
Jon Slaughter wrote:
>I assume this is bash stuff? (I haven't done any unix scripting in a very
long time and very little but I assume the other posts give the script
that
will work here). I just remember there being several types

Cron doesn't specifically require bash scripting.

Cron can be used to launch any executable file at a frequency of up to
once per minute. (Or as infrequent as once every 28 years[1] if need be,
but that seems a bit excessive -- if something needs scheduling that
infrequently, you're better off running it manually.)

These executables could be bash scripts, tcsh scripts, Perl scripts,
compiled C code, or raw machine code written in a hex editor if you
like -- anything that you could run from the command line can run from
cron.

That said, most people do seem to use either Perl or some form of shell
scripting for cron jobs.
Thanks... I'll try to do some more research on it and see what I come up
with... on what to do. I like the idea of using php but I think it won't be
fast enough so I'll look into doing it in C++ and then figure out how to run
it(since I'm on a windows machine I'll have to compile it for linux somehow)

Jon
Jun 5 '07 #13
On Jun 5, 9:34 pm, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
"Toby A Inkster" <usenet200...@tobyinkster.co.ukwrote in messagenews:un************@ophelia.g5n.co.uk...
Jon Slaughter wrote:
I assume this is bash stuff? (I haven't done any unix scripting in a very
long time and very little but I assume the other posts give the script
that
will work here). I just remember there being several types
Cron doesn't specifically require bash scripting.
Cron can be used to launch any executable file at a frequency of up to
once per minute. (Or as infrequent as once every 28 years[1] if need be,
but that seems a bit excessive -- if something needs scheduling that
infrequently, you're better off running it manually.)
These executables could be bash scripts, tcsh scripts, Perl scripts,
compiled C code, or raw machine code written in a hex editor if you
like -- anything that you could run from the command line can run from
cron.
That said, most people do seem to use either Perl or some form of shell
scripting for cron jobs.

Thanks... I'll try to do some more research on it and see what I come up
with... on what to do. I like the idea of using php but I think it won't be
fast enough so I'll look into doing it in C++ and then figure out how to run
it(since I'm on a windows machine I'll have to compile it for linux somehow)

Jon
php offloads some of its work onto c libraries anyway, so unless you
have a specific task in mind that php does not offload, you might not
find too much diff in perf, my $0.02

Jun 6 '07 #14
Jon Slaughter wrote:
>You may or may not have the ability. It depends on the permissions the
host gave you. Some allow cron jobs, some don't.

Now is that really the only way to schedule stuff in a linux enviroment? I
mentione dthe crond int eh subject cause thats all I know about.

What I'm trying to get at, is it going to be impossible to schedule stuff if
the host doesn't have it setup to do that? Obviously it can be impossible
but here I mean in general for most web hosts is it a common thing to allow
or deny?

Also is there any way to check for schelduling abilities? I have no shell in
the web host I think... just ftp and http.

oh, wait, I think I do have schelduling abilities... in the control panel
stuff for the site. I'll have to go check and see as I remember seeing that.

Thanks,
Jon

As I said - it's all up to the host. Some disable it because abuse can
affect system performance.

And yes, that is the scheduler for Linux. You can probably find some
other programs which emulate it, but cron is built into the system and
works the best. And if they disabled cron, chances are there is a
reason and they would be upset if you tried to bypass it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 6 '07 #15
On 5 Jun., 16:13, "Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote:
"shimmyshack" <matt.fa...@gmail.comwrote in message

news:11**********************@p77g2000hsh.googlegr oups.com...
On Jun 5, 7:21 am,Lammi<Lorenz.Lammersd...@gmail.comwrote:
you mentioned it in the subject of your post - use cron.
>http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
it's possible to call a php script via cron directly or you call a
small shellscript, that open the php, f. e.
#!/bin/sh
# execute php script
# -q =quiet, suppress the php-header
php -q /home/mysql/script.php
if you can use cron cos you are on windows, use cronw instead. You can
also register your script as a service and start that every day (the
service could self-stop after its work is done) then you could use a
line such as
"service name" start
in cron
I dont see a point to registering as a service, but I mention it just
for fun!

Actually guys, I have no idea how to run a script or anything on the web
host's server but I assume they have this ability? (to schedule maintenance)

I think its a linux platform so I image they have crond or something like
that. There web site forum was down last time I checked so I haven't found
out whats really going on.

Thanks,
Jon
oh it's a hosted server? ask your hosting provider if cronjobs are
possible. if not (or if you don't wanna ask :-) ), try
http://www.cronjob.de/ f. e. (i'm sure there are similar services in
english).

Jun 7 '07 #16
At Tue, 05 Jun 2007 03:32:30 +0000, Jon Slaughter let h(is|er) monkeys
type:
How do I create a process that will be called periodically to do some task?
This is not necessarily php but not sure where to ask.

Essentially I want to create either a php script or app(C++ would be nice)
to run once a day that will generate a set of images to be used for
captchas.

Any ideas or ideas where I can look for more info?

Thanks,
Jon
You could have your captcha-using script check the number of times your
current set of captchas has been 'used' or subtract the time you last
created captcha images from the current time and start the regeneration of
a new batch instead of having to use cron or at.

In practice, I would only worry about overtaxing the server if you have a
massive number of visits each day. The imagefunction set provided by gd is
pretty well opimised, your own C/C++ program might have a challenge trying
to beat it.

I've yet to see the first problem on a site I oversee creating captchas on
the fly. Even on relatively low-end shared environments.

I think you may be worrying about something that may never be a real
problem here.
--
Schraalhans Keukenmeester - sc*********@the.Spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]

"strcmp('apples','oranges') < 0"

Jun 10 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Arkascha | last post by:
Maybe someone can give me a short help with this... I got a server application in a LAMP environment doing batch tasks. A cronjob serves as a regular trigger, a metronom. The trigged...
2
by: T Stoneman | last post by:
I was wondering if PHP has some type of initialization functionality at startup where I can run a script when the web server first boots up? I have an Apache server running PHP, and I would like...
18
by: Klaus Alexander Seistrup | last post by:
Hi, After upgrading my Python interpreter to 2.3.1 I constantly get warnings like this: DeprecationWarning: Non-ASCII character '\xe6' in file mumble.py on line 2, but no encoding declared;...
3
by: Laurent Vincelette | last post by:
I have a python script (file start with #!/usr/bin/python) that use xmlrpclib to lessen and respond on port:8000. The problem is when I close the shell (bash in remote with putty) the script stop...
22
by: James Kupernik | last post by:
Hello everyone! I'm hoping someone can shed some light on my ever daunting mysql/php problem. I'm currently trying to get a new server up and running using apache/php/mysql. Everything runs...
0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
0
by: Benoit St-Jean | last post by:
I am wondering if the "swap bug" is present on my kernel/version of RedHat 9 as described at: http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89226 It looks like the OS prefers to fill the...
1
by: kardon33 | last post by:
What i need to do is write a shell script that finds the pid of crond and kill that. All i need to know is how to set a variable with the result of "pidof cond" and kill that variable.
3
by: xtremebass | last post by:
Hi , I am want to run the shell script to run every 10 minutes of interval ,so that i have used crontab command for scheduling the shell script .. it cant works . i have checked wall command in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.