How to create an Automatic Task

I have linux/redhat/apache server and all my stuff is written in php
how can i create an automatic task, for example i have a code
that sends reports to customers.
I want this code to be launched lets say every Monday at 10am.

where can i create this schedule?
LVL 1
CMDAIAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

0renCommented:
use crontab
0
0renCommented:
to add a task lets say a script called /usr/local/bin/do_something

open crontab by using

crontab -e

to add a task


00 2 * * * /usr/local/bin/do_something

# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
0renCommented:
if crontab -e does not opening any text editor then you must set the environment variable  EDITOR or VISUAL
to do it :
export EDITOR=vi
or
export EDITOR=/usr/bin/gedit

to view all tasks in crontab run
crontab -l

each user has his own crontab files.

also make sure the file /etc/cron.deny does not contain your username
and if the file /etc/cron.allow exist make sure your name is in it.
if you dont need to allow or deny crontab just remove them both
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

0renCommented:
to run a task every monday at 10am
00 10 * * 1 /task/to/run
0
omarfaridCommented:
to run scripts/tasks on linux, take the following points into consideration

1- make the script executable (use chmod command)
2- set required env. variables since cron will not read the user .profile file
3- refer to files amd commands with full path names e.g. /usr/bin/cp
4- redirect stdin/stdoout/stderr as required

0
CMDAIAuthor Commented:
Thank's that does it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.