cron

How to run console command in yii2 from web

偶尔善良 提交于 2020-01-13 08:26:48
问题 I have created a console command in console/controllers with SuggestionController . If i run command like php yii suggestions , its working. I want to know how to execute console command from web without any extensions of yii2 . 回答1: It can be done much simpler $oldApp = \Yii::$app; new \yii\console\Application([ 'id' => 'Command runner', 'basePath' => '@app', 'components' => [ 'db' => $oldApp->db, ], ); \Yii::$app->runAction('migrate/up', ['migrationPath' => '@yii/rbac/migrations/',

Restart pm2 app every 12h with cron

南笙酒味 提交于 2020-01-13 08:19:28
问题 Tried this, but it doesn't work: SHELL=/bin/bash PATH=/usr/lib/node_modules/pm2/bin * 0,12 * * * pm2 restart all What am I doing wrong? 回答1: Edit cron with crontab -e and add the following: 0 */12 * * * /usr/bin/node /usr/bin/pm2 restart all For the schedule, use 0 */12 * * * for every 12 hours, or 0 0,12 * * * for 0:00 and 12:00 specifically. (Your schedule, * 0,12 * * * , would trigger every minute of hour 0 and hour 12, 0:00, 0:01, 0:02...) For the command, as fedorqui mentioned, use the

cron job in wordpress

谁都会走 提交于 2020-01-13 07:30:28
问题 I want to run a cron job in wordpress using the default function. I want set the time to run every 15 days. How can I set the the for this? function prefix_deactivation() { wp_clear_scheduled_hook('prefix_hourly_event_hook'); } register_deactivation_hook(__FILE__, 'prefix_deactivation'); function prefix_activation() { wp_schedule_event(time(), 'everyminute', 'prefix_hourly_event_hook'); } register_activation_hook(__FILE__, 'prefix_activation'); /* On activation, set a time, frequency and name

Any way to run Firefox with GreaseMonkey scripts without a GUI/X session

耗尽温柔 提交于 2020-01-13 05:26:31
问题 I need to build a small "monitoring" scraper for a 3rd party website (it's an external website that has stats about our visitors). Unfortunately, this website is very hard to scrape through the normal "wget" mechanism, because it uses a ton of sophisticated JS, part of it generated by GWT. So my workaround was to create a GreaseMonkey script and then have this script call a PHP page that would log the scraped data. Then as soon as Firefox starts with this webpage-to-scrape, the script goes to

How can I log “show processlist” when there are more than n queries?

北战南征 提交于 2020-01-12 20:30:15
问题 Our mysql processes can sometimes get backlogged and processes begin queuing up. I'd like to debug when and why this occurs by logging the processlist during slow times. I'd like to run show full processlist; via a cron job and save output to text file if there are more than 50 rows returned. Can you point me in the right direction? For example: echo "show full processlist;" | mysql -uroot > processlist-`date +%F-%H-%M`.log I'd like to run that only when the result contains the text 50 rows

How can I log “show processlist” when there are more than n queries?

ぃ、小莉子 提交于 2020-01-12 20:29:51
问题 Our mysql processes can sometimes get backlogged and processes begin queuing up. I'd like to debug when and why this occurs by logging the processlist during slow times. I'd like to run show full processlist; via a cron job and save output to text file if there are more than 50 rows returned. Can you point me in the right direction? For example: echo "show full processlist;" | mysql -uroot > processlist-`date +%F-%H-%M`.log I'd like to run that only when the result contains the text 50 rows

Cronjob with password protected site (.htaccess)

有些话、适合烂在心里 提交于 2020-01-12 18:47:17
问题 I want to create a cronjob that every X time goes to open a webpage. This webpage is password protected by .htaccess (user=admin, passwor=pass). The instruction I give is the following: wget --user=admin --password='pass' http://www.mywebsite.com/test.php But cron gives me the following error: --2012-05-02 10:14:01-- http://www.mywebsite.com/test.php Resolving www.mywebsite.com... IP Connecting to www.mywebsite.com|IP|:80... connected. HTTP request sent, awaiting response... 401 Authorization

Cronjob with password protected site (.htaccess)

时光毁灭记忆、已成空白 提交于 2020-01-12 18:45:41
问题 I want to create a cronjob that every X time goes to open a webpage. This webpage is password protected by .htaccess (user=admin, passwor=pass). The instruction I give is the following: wget --user=admin --password='pass' http://www.mywebsite.com/test.php But cron gives me the following error: --2012-05-02 10:14:01-- http://www.mywebsite.com/test.php Resolving www.mywebsite.com... IP Connecting to www.mywebsite.com|IP|:80... connected. HTTP request sent, awaiting response... 401 Authorization

Auto delete Wordpress users according to time since registering?

泄露秘密 提交于 2020-01-12 08:48:06
问题 On a basic Wordpress 3.1 setup with User Access Manager, is it possible to automatically delete users that are x days old? I have found no plugins for this feature. How would one go about implementing this? Would I be able to set up a cron job with an sql or php query whereby users that are for example 3 days old are automatically deleted from the database once every day? If so, could someone please explain how? Any help would be greatly appreciated - thanks in advance. 回答1: You want to have

Cron Job $_SERVER issue

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-12 03:05:33
问题 I want to run a cron job. My application is developed in PHP and Mysql. In browser if i use $_SERVER[HTTP_HOST] in coding, it works fine. But if I use the same thing in cron job it is giving errors. Can any body give suggestion to fix this? 回答1: $_SERVER['HTTP_HOST'] is not populated when running it from a cronjob, the file is not accessed via HTTP. You will either have to hardcode the Host or pass it via a command line argument and access it via the $_SERVER['argv'] array. 回答2: When php is