cron

Execute Node.JS script via crontab on OS X

坚强是说给别人听的谎言 提交于 2021-01-28 07:53:41
问题 I have been trying to figure out how to use crontabs on my mac OS X I have a node script written that I would like to be able to execute in a scheduled manner. Here is the line I am using in my crontab file. 30 * * * * /usr/local/bin/node /Users/pmanca/Google Drive/JavaScript/code/Peter/marketing-tests/testBackup.js It doesn't appear to be executing though. Can anyone see what I am doing wrong? Also is there another way on a mac or linux server to accomplish what I'm looking for? Also can you

How can I run a PHP Script automatically Daily in WAMP / Windows Environment?

帅比萌擦擦* 提交于 2021-01-28 03:41:36
问题 I need to run a PHP script at the scheduled time daily to update some fields in database. How I can do this? I tried with windows scheduler and it not running the script I cant figure our the error. Is there any tutorial or steps which helps to understand the working, so as to configure. My Bat File: H:\wamp\bin\php\php5.5.12\php.exe H:\wamp\www\file\file.php Test PHP Script: <?php $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); $txt = "John Doe\n"; fwrite($myfile, $txt);

Selinux blocks the crontab command from php

独自空忆成欢 提交于 2021-01-28 03:27:47
问题 There are Fedora 25 and apache on our server. I want to do so that the php script on our web site can change crontab settings. I created the following test php script: <?php system("echo '*/2 * * * * date > /var/www/logs/testlog.txt' | crontab - 2>&1"); But it did not work. I got the message: /var/spool/cron/#tmp.mh203-95.XXXXG0KrFF: Permission denied I looked at output of sealert -a /var/log/audit/audit.log and found: SELinux is preventing crontab from write access on the directory /var

php exec crontab not working

北城以北 提交于 2021-01-28 02:22:30
问题 I trying on my local CentOS 5.3 server, when I try to execute below line in my php code from apache webserver exec("crontab -l", $output, $arg); The $arg reply 127 (command not found code) Then I changed below code exec("/usr/bin/crontab -l", $output, $arg); The $arg reply 126 (Permission problem code) Here is my current permission of /usr/bin/crontab -rwsr-sr-x 1 root root 311288 Mar 15 2007 /usr/bin/crontab. And there is no /etc/cron.allow and /etc/cron.deny file. I already turned off Safe

Trying To Fetch The Latest Reddit Post With The Reddit API

谁说我不能喝 提交于 2021-01-28 01:25:10
问题 I am attempting to scrape an url from reddit and post it on my blog every 30 minutes. This is my current solution: I created a php file named 'newpost.php' that fetches content from the reddit's api and posts it to my blog. (Every time the page is loaded it fetches/posts the newest reddit post). Here is the code: $json = file_get_contents("https://www.reddit.com/r/all/new.json?limit=1"); $obj = json_decode($json); $url = $obj->data->children[0]->data->url; // the rest posts this url to my

I cannot list up the BLE devices in the neighbourhood of my Raspberry Pi (python, btmgmt)

谁说我不能喝 提交于 2021-01-27 18:52:27
问题 I want to scan the ble devices in the environment of my Raspberry, by using a python script called from a cron script. But when I do this in cron (I mean I added to sudo crontab -e), I allways end up with an empty list. when I am logged in as pi user - btmgmt works (only) fine with su permissions: pi@Pluto:~ $ btmgmt find Unable to start discovery. status 0x14 (Permission Denied) pi@Pluto:~ $ sudo btmgmt find Discovery started hci0 type 7 discovering on hci0 dev_found: 77:F8:D7:8A:1E:E5 type

Cron wont import pandas module to execute python script. ```ImportError: No module named pandas```

懵懂的女人 提交于 2021-01-27 18:24:07
问题 I am using xubuntu 18.01 I have a python program that that scrapes weather data and saves the files as a csv. It works perfectly running the command weatherdata in terminal after i gave it permission using chmod +x weatherdata . I would like this to run every 2 weeks using cron. But nothing happens after i set it up. I am using the NANO cron editor I have set the cronjob up trying PATH variables, SHELL=/bin/bash/. P Putting the /bin/bash in front of the command... all to no avail.... #

Cronjob: Command Not Found

北战南征 提交于 2021-01-27 17:19:00
问题 I have a cronjob that is the following: */10 * * * * root cd /some/directory && python3 FILE.py >> Output.txt 2>&1 if i run that command from a regular command line, it works fine. But when ran from cronjob, I get /bin/sh: python3: not found But when I run echo $PATH it returns /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/usr/local/python3/bin:/opt/bin (Note that /usr/local/python3/bin is included in this directory How do I fix this? 回答1: It seems

Cronjob: Command Not Found

流过昼夜 提交于 2021-01-27 17:07:59
问题 I have a cronjob that is the following: */10 * * * * root cd /some/directory && python3 FILE.py >> Output.txt 2>&1 if i run that command from a regular command line, it works fine. But when ran from cronjob, I get /bin/sh: python3: not found But when I run echo $PATH it returns /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/usr/local/python3/bin:/opt/bin (Note that /usr/local/python3/bin is included in this directory How do I fix this? 回答1: It seems

springboot项目redis分布式锁实现(基于luttuce)

左心房为你撑大大i 提交于 2021-01-27 11:17:51
问题背景 对于大部分的后端服务,服务很多都是多实例部署的,而在我们的工程中,比如说代码中定义的定时任务需要从数据库中捞数据,那么多机部署上的每个实例都会执行,那么就会存在数据重复上报,那么就不可避免得出现脏数据,影响数据的准确性。 问题分析 解决这个问题最直接的思路就是,当多机部署中无论哪个实例捞到了某条数据,那么其他的实例就不能再次捞取。针对这个思路,我们大致可以有以下两个解决方案: 1. 在数据库层解决。给访问的数据表中,增一个字段flag,标识是否已经上报过,每个实例上报一条,就更新一下这个状态,后面的实例再读到这一条时,发现上报过了,就不处理了。这就要改一下现在的读取方式,需要从数据库中逐条读取,避免脏数据。 2. 引入分布式锁,最简单的,就用redis实现,每个实例开始定时任务前,先尝试在redis中获取锁,如果获取得到,这个实例的定时任务就执行,否则就跳过。 对于第一个解决方案的实现本文不予说明,这种实现方式虽然可行,但是对于频繁更新数据库的操作我个人是非常不推荐的,性能方面可能会受到影响。本文主要想介绍一下方案2的实现。 方案实现 对于多机部署的问题,自然而然就可以想到分布式锁来保证任务执行的准确性。在Springboot项目中,最直接就是通过redis实现,我们知道,从Springboot 2.X开始,底层的redis客户端从Jedis换成了luttuce