0

I have the code for cron job but i don't know where place this code in my project folder.

The code is:

00 * * * * /usr/local/bin/php /home/cnl/myscript.php
Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123
Vinod Khatik
  • 121
  • 1
  • 2

1 Answers1

0

No, You can't. You can't place OS(crontab) configuration code to PHP code and expect that it will manage your OS. But You can:

1) Create method at CodeIgniter's controller (for example at application/controllers/welcome.php create

function hello(){
   echo "I'm a function!";
}

and then call it from command line as

cd /your/path/to/codeigniter/ && php5 index.php welcome hello

If it works correctly, add this task to You crontab via command line or some GUI (cPanel/ISPManager/VestaCP/etc)

2) If You need to add Your line to cron and in fact Your question is not connected to CodeIgniter, I advice You to search "how to add cron job?", You'll find many results

Egor Sazanovich
  • 4,979
  • 5
  • 23
  • 37