So I'm writing a script that must do certain things daily and I could set a cron job but I want to also share the script as a free download, and I want the script to just work for my users, no set-up, so I'm trying to find a way that, if the user is using Linux, or IIS or whatever that as long as they support PHP (or at least for most servers if I can't do it for all) the script will be able to execute a daily process on time each day.
Goldfinch
0
Newbie Poster
Recommended Answers
Jump to PostI don't get it?
What kind of cron job is it? Are you running a specific file on YOUR server that you want other people to be able to have on their server and execute YOUR FILE from their server?
Jump to PostI think the only way to do this is using cronjobs, since the PHP has to be executed. I don't think there is anyway to make a PHP script that runs itself.. I don't get what the purpose of this would be anyway?
Jump to Post@Goldfinch - Ok, I have a Linux box and I'll connect to it and try and write a script for you to do this. It might not pay off and someone could come up with an answer before me, but, hopefully, it will work.
Jump to PostI think this code will work:
<?php $filename = "../../tmp/crontask.txt"; $output = shell_exec('crontab -l'); $something = file_put_contents($filename, $output.'* * * * * NEW_CRON'.PHP_EOL); $cngDir = chdir('../../tmp/'); $exe = exec('crontab crontask.txt'); var_dump($exe); ?>
There is a lot of issues around permissions though, good luck! Let me know …
All 15 Replies
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
commented:
thank you, that's very kind
+1
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
Goldfinch
0
Newbie Poster
Goldfinch
0
Newbie Poster
phorce
131
Posting Whiz in Training
Featured Poster
Goldfinch
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.