You are here: Re: Execute crontab as user Joe using php... « PHP Programming Language « IT news, forums, messages
Re: Execute crontab as user Joe using php...

Posted by Erwin Moller on 03/23/07 14:47

Chr1s wrote:

> How do I execute a crontab command using php (not CLI) as user Joe?
>
> I don't have any problem getting output from commands such as 'ls'
> using passthru and exec but I am stumped with crontab.
>
> Many thanks!
>
> Chris

Hi Chris,

1) user Joe:
If you want user Joe to execute the cronjob, login as use Joe and edit his
cronjob by typing:
crontab -e

Now the contab program opens Joe's cronjobs.
Most systems open in VI editor, since I hate that thing because I am a nOOb,
I prefer opening in pico: a small editor that works like a human brain,
unlike VI (shoot me if you want. :P).

If you want pico (or nano) too, type first:
export EDITOR=pico
then give the crontab -e command.

2) shedule
add a line like this (all on 1 line):
0 1 * * * cd /home/yourdir/public_html/ && php -q
/home/yourdir/public_html/yoursheduledscript.php

to let the script run each night at 1 o'clock.

I am not sure about the cd, but had trouble using a script without cd-ing to
the dir first.

Hope that helps.

Good luck.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация