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 Chr1s on 03/23/07 17:34

On Mar 23, 2:50 pm, Erwin Moller
<since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
> Erwin Moller wrote:
> > 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
>
> One addition: when hunting for problems think of the cronjob as:
> 1) login as user Joe
> 2) Joe gives the commands by hand.
>
> So if your script isn't doing what you want, you can always try to find what
> is wrong by doing excactly the same thing being Joe.
>
> Good luck.
>
> Regards,
> Erwin Moller- Hide quoted text -
>
> - Show quoted text -

Apologies, I should have been more specific.

I want to append to a user's crontab using a php script...not run a
script from crontab.

For example,

exec('crontab MyFile', $var);

I don't know how to adapt this code to work for user 'Joe'?

Thanks,

Chris

 

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

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