Response
stringlengths 8
2k
| Instruction
stringlengths 18
2k
| Prompt
stringlengths 14
160
|
---|---|---|
I believe that you should place only absolute paths in your cronjobs. As seen in your question, you wrote:./aws-cron-job/Ap_Hourly_xxxDelete.shand I think you should write:/<rootpath>/aws-cron-job/Ap_Hourly_xxxDelete.sh
|
I get this error while running thru crontab/aws-cron-job/Ap_Hourly_xxxDelete.sh: 1: ./aws-cron-job/Ap_Hourly_xxxDelete.sh: ec2-describe-snapshots: not found./aws-cron-job/Ap_Hourly_xxxDelete.sh: 1: ./aws-cron-job/Ap_Hourly_xxxDelete.sh: ec2-delete-snapshot: not foundThis is my script: filename =xxx.shec2-delete-snapshot --region ap-southeast-1 $(ec2-describe-snapshots --region ap-southeast-1 | sort -r -k 5 | grep "Ap_Hourly" | sed 1,4d | awk '{print $2};' | tr '\n' ' ')This is mycronjob:30 05-15 * * 1-6 ./aws-cron-job/Ap_Hourly_xxxDelete.sh > ./aws-cron-job/Ap_Hourly_xxxDelete.txt 2>&1I can run this script manually but not through Cronjob. Where is the problem in this. Thanks in advance.
|
Sh Script runs fine manually, fails in crontab
|
You can easily accomplish what you need with Task API. When you create a task, you can set an ETA parameter (when to execute). ETA time can be up to 30 days into the future.If 30 days is not enough, you can store a "send_email" entity in the Datastore, and set one of the properties to the date/time when this email should be sent. Then you create a cron job that runs once a month (week). This cron job will retrieve all "send_email" entities that need to be send the next month (week), and create tasks for them, setting ETA to the exact date/time when they should be executed.
|
I want to be able to schedule an e-mail or more of them to be sent on a specific date, preferably using GAE Mail API if possible (so far I haven't found the solution).Would using Cron be an acceptable workaround and if so, would I even be able to create a Cron task with Python? The dates are various with no specific pattern so I can't use the same task over and over again.Any suggestions how to solve this problem? All help appreciated
|
Is there a way to schedule sending an e-mail through Google App Engine Mail API (Python)?
|
The cron job should not be connecting to the pages; it should be the reverse: use the backend pages themselves to check for job completion. You can useServer-Sent Events(SSE) for this. The process would be:1Backend pages (Javascript) subscribe to an SSE channel and show a popup when the PHP script emits an eventvar source = new EventSource("job_checker.php");
source.onmessage = function(event) {
//event contains the job info and deadline. you can display it
var jobDetails = JSON.parse(event);
...
};2The PHPjob_checker.phpcan run through a loop for a set amount of time, checking for job completion:<?php
$time_limit = 300; //300 seconds
$time_spent = 0;
while($time_spent < $time_limit){
sleep(30); //sleep for 30 seconds
$time_spent += 30;
//check DB for job completion and deadline.
//if you find a job, emit an SSE to the browser
if($event_found){
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
echo "data: ". json_encode($event_found)."\n\n";
flush();
}
}The PHP script will keep working for 300 seconds. If it finds an event, it will emit data and the browser will get it. After 300 seconds, the script will die. If the user still has the admin page open, the browser will automatically reconnect. If the user has closed the page, the resources will be freed.Moredocs from Mozilla: (thanks to Alok Patel for the link)
|
Closed. This question needs to be morefocused. It is not currently accepting answers.Want to improve this question?Update the question so it focuses on one problem only byediting this post.Closed7 years ago.Improve this questionI have following scenario.
When any complaint opened for job isn't completed within 48 hours and if that complaint is nearing 48 hours without completion, popup or notification should be there in backend before the time limit(say 1 hour before).
I am thinking of doing cron job(run every hour).My problem is how to do the notification in cron job.
Any suggestion will be welcome.
|
can cron job be used to show notification in php web [closed]
|
Event triggers will generate events on an event stream with name same as the event trigger, having only one attribute with name "triggered_time" and type long. Basically, once the trigger emits an event, it behaves similar to an event stream. Therefore, we can put both cron events, start events in to a event stream and use it.define trigger cronTriggerStream at '0 0/15 * * * ?';
define trigger startTriggerStream at 'start';
from cronTriggerStream
insert into periodicalTriggerStream;
from startTriggerStream
insert into periodicalTriggerStream;
|
I have the next CronExpression in Siddhi (wso2 DAS):define trigger periodicalTriggerStream at '0 0/15 * * * ?';This expression is runing without problems, run every 15 mins15, 30, 45 ....I need that my trigger run when I start SIDDHI.0, 15, 30, 45Is posible combine two expressions?:define trigger periodicalTriggerStream at '0 0/15 * * * ?';
define trigger periodicalTriggerStream at 'start';
|
Combine two Cronexpressions
|
If you were to trycrontab -h, which is usually the help option, you'll get this:$ crontab -h
crontab: invalid option -- 'h'
crontab: usage error: unrecognized option
Usage:
crontab [options] file
crontab [options]
crontab -n [hostname]
Options:
-u <user> define user
-e edit user's crontab
-l list user's crontab
-r delete user's crontab
-i prompt before deleting
-n <host> set host in cluster to run users' crontabs
-c get host in cluster to run users' crontabs
-x <mask> enable debugging
Default operation is replace, per 1003.2The line to note is the one that says-l list user's crontab. If you try that, you see that it lists out the contents of one's crontab file. Based on that, you can run the following:import subprocess
crontab = subprocess.check_output(['crontab', '-l'])Andcrontabwill contain the contents of one's crontab. In Python3 it will return binary data so you'll needcrontab = crontab.decode().
|
I am trying to use the contents of a crontab inside a python script. I want to do everything using python. In the end I hope to take the contents of the crontab, convert it to a temporary textfile, read in the lines of the text file and manipulate it.Is there any way i can use the contents of the crontab file and manipulate it as if it were a text file???I've looked into the subprocess module but am not too sure if this is the right solution....NOTE:I am not trying to edit the crontab in any way, I am just trying to read it in and manipulate it within my python code. In the end, the crontab will remain the same. I just need the information contained inside the crontab to mess with.
|
Using Crontab in a Python Script
|
Cron passes only minimal set of environment variables to your jobs. Seehere!Add -lc option to bash for cron execution to use your login environment and set environment path at the top of your crontab.PATH=$PATH:/usr/bin:/bin:/usr/local/bin
* * * * * /bin/bash -lc "cd ~/home/path/application && RAILS_ENV=development bundle exec rake namespacefolder:rake_file"
|
I've below command in crontab, when I run this command in terminal it works fine but when I run this in crontab am getting the following error* * * * * cd /home/path/application && RAILS_ENV=development ./bundle exec rake namespacefolder:rake_fileError:bundler: command not found: rake
Install missing gem executables with `bundle install`someone please help.
|
Crontab throws error
|
Second Minute Hour Day-of-month Month Day-of-week Year (optional)0 * * * *
First second of every minute of every hour of every day of every month?
Specifies no particular value. This is useful when you need to specify a value for one of the two fields Day-of-month or Day-of-week, but not the other.
|
please tell me the meaning of "0 * * * * ?" at cronExpression.<bean id="batchJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="batchJobDetail"/>
<property name="cronExpression">
<value>0 * * * * ?</value>
</property>
</bean>
|
cronExpression 0 * * * *?
|
Try this with the escaping of a\prior to the%30 2 * * * /usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +\%Y-\%m-\%d-\%H.\%M.\%S).sql.gzSeeUsing the % Character in Crontab Entriesby M. Ducea
|
Hi fellow StackOverFlow,Today , I have a very weird scenario in my Unix machine.I'm currently using this command manually to save my current database backup./usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +%Y-%m-%d-%H.%M.%S).sql.gzIn my crontab , I access it usingcrontab -eThen I add the following to the list30 2 * * * /usr/bin/mysqldump -u root -p'thetechnofreak' admin_test > /mnt/databasesql/admin$(date +%Y-%m-%d-%H.%M.%S).sql.gzI realize that it's not doing it automatically, is there anything that i've missed?Is there a flagging option or a logging method to know whether the backup is done successfully or not.Thanks in advance.
|
Linux Backup MySQL failed when assign to crontab
|
If you want to get details of the newly inserted data, add a new column in your table likeadd_date. Check this add_date equals to current date. If yes you will get the details of every day's new date. You can use the below code.$today = date("Y-m-d");
$check_new_data = mysql_query("SELECT name,amount, trans_id, msisdn, time_paid FROM
customer WHERE add_date='$today'");
while($check = mysql_fetch_array($check_new_data))
{
echo "What ever date you need";
}
|
I want to select and use ONLY new records that have been inserted between a Cron job runs and the next run. In this sense I don't repeat any data or records that I worked on earlier.From the select statement below, please someone direct me, thank you.// select statement should pick fresh records only after the first cron
$sql = "SELECT name,amount, trans_id, msisdn, time_paid FROM customer";
$result1 = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result1); // fetch data
$name = $resultarr['name'];
$amount = $resultarr['amount'];
$transaction_id = $resultarr['trans_id'];
$date = $resultarr['time_paid'];This is important because the data will be used to send an SMS and I don't want to send an SMS twice to someone.Kindly, anyone?
|
mysql select statement to pick only newly inserted records after cron job run
|
In case your script doesn't output anything, the output file is not "touched", i.e. modification time is not updated. But you can add "touch" explicitly in this case:*/5 * * * * /path/to/script.sh >> /tmp/script.out 2>&1; touch /tmp/script.outBy the way,echoemptyoutput is not really empty, it produces newline character (i.e. LF = line-feed) :$ echo | hexdump -c
0000000 \n
|
I have cron job working in the form of:*/5 * * * * /path/to/script.sh >> /tmp/script.out 2>&1When redirecting an emptyecho's output and appending it to an output file the modification date changes.
My question is if in the cron's output file this occurs as well?I would like to know this to verify when the file was last executed without having to write into the file on purpose.
|
Does a cron job touch the output file
|
The most common error is that the environment-variables not bound andjava is not in pathJAVA_HOME is not set.Try*/5 * * * * java -jar /var/www/java/executable.jar > /var/log/javacron.log 2> /var/log/javacron-err.logand inspect the/var/log/javacron.log-file for more informations.
|
I have a .jar which I can run perfectly via the command line.I need this to be running continuosly every 5 mins, so i did crontab -e where I added this line*/5 * * * * java -jar /var/www/java/executable.jarif I gogrep CRON /var/log/syslogI do see where the job was executed, but it never was since I have a logger inside the java file and the first thing it does is append to the logger the time, which is not doing so.What can be the possible error?
|
crontab not running java
|
The cron may need to run the script from the directory it's in. You could update the crontab tocdto the script directory, then execute it, like so (example):0 12 * * * cd /path/to/your/script/ ; php your_script.php > /dev/null 2>&1
|
I have 2 server one is with cPanel and other is without cPaneli am running same php scripts as cron jobs on both servers.All scripts are running fine on cPanel server but on non-cPanel server i am gettingfile not found errorFailed opening required '../includes/config.php'i have 15+ cron job php scripts.is there any way tofix this without editing all my php scripts and adding __FILE__on all includes and required?how all these scripts running fine on cPanel without __FILE__?
|
php cron jobs working fine on cPanel server but giving errors on non cPanel server
|
You don't need to create a special file nor you need any kind of hacks to get it working.Simply, You create a controller & request it through index.phpYour cron command should look like this/usr/bin/php -q /path/to/codeigniter/index.php controller_name methodassuming your controller is named 'cron' & your method is 'reccuring_checks' it would be something like this/usr/bin/php -q /path/to/codeigniter/index.php cron reccuring_checksLimiting your controller to command line access only is as simple as follows:class Cron extends CI_Controller {
public function __construct () {
parent::__construct();
// Limit it to CLI requests only using built-in CodeIgniter function
if ( ! is_cli() ) exit('Only CLI access allowed');
}
}If your hosting provider is using cPanel control panel, Your PHP path should be as follows:/usr/local/bin/php
|
I'm trying to set up a cron to run a codeigniter controller/method.I have my application and system file etc outside of the root.I have created a cli.php file as a hack to get it working, as suggested by someone on the codeigniter forums. the content of the file are:if (isset($_SERVER['REMOTE_ADDR'])) {
die('Command Line Only!');
}
set_time_limit(0);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'] = $argv[1];
require dirname(__FILE__) . '/public_html/index.php';Now, I can successfully run the controller/method via cli using this termical command:php cli.php cron/reccuring_checksBut can I get it to run as a cron?? oh dear NO i cannot, been at this for a whole day.I've tried: (as well as 1000 different other combinations)php cli.php cron reccuring_checks
/usr/bin/php -q /home/DOMAIN/cli.php cron/reccuring_checks
/usr/bin/php -q /home/DOMAIN/cli.php cron reccuring_checksI get the following error<p>Severity: Notice</p>
<p>Message: Undefined index: REMOTE_ADDR</p>
<p>Filename: drivers/Session_files_driver.php</p>
<p>Line Number: 130</p>And a lot of the posts I can find online about this generally relate to CI2 and the method of replacing:$_SERVER['REMOTE_ADDR'] with $this->server('remote_addr')In the system/core/input file, but that is already amended in CI3So has anyone got a clue how I can get this to work?I assume the issue is that I have the core files above root, but thats what CI suggest you do for security, and I'm way to far down the line to change it now?
|
Codeigniter 3 CRON via CLI not working
|
While running from crontab you cannot rely upon any environment variables, TTY, or paths. Sounds like you've got paths sorted but the mailer may be expecting to know something about you. Try running your script without your environment, to get meaningful messages about what your problem is: su {your_name} -c {your script}
|
I have aperlscript that executes a command. I am saving the output of this command to an array and checking the content on the output to mail me a success or a failure message.This works fine when i run the script itself. But when i schedule the script to run as acronjobi get a failure mail irrespective of the output.I am using all theabs pathsin script and know the cron is executing since i see in my logs that thecommand is executed successfully.Can someone tell me why the difference?One thing to notice is, the command takes about a minute to finish executing and the script is waiting till the command is executed to check the output. So i am seeing a little delay in the mail when i run the script. But in the cron, i get a mail immediately at the run time. I am assuming the cron isn't waiting for the command to execute and check the output.Could that be the case?
|
Different mail from shell script and cron running the script
|
default shell on ubuntu is /bin/dash so /bin/sh will be a symlink to that.sourceis a bash builtin. to run cron jobs as bash putSHELL=/bin/bashin the cron file
|
Previously was using Fedora, and I was calling cron jobs using this method, which worked perfectly:source /home/me/miniconda/bin/activate me_dev; python /home/me/avant_bi/g_parse.pyNow this throw an error in the cron logs:/bin/sh: 1: source: not foundI've tried switchingsourcefor a.to no avail, as I read something I didn't fully understand about Ubuntu cron not working with the source call.I've also tried/home/me/miniconda/envs/me_dev/python /home/me/avant_bi/g_parse.pyWhich is the location of the python I use when I activate the environment generally, but that seemingly is doing nothing (no logs of it running in cron).I've tried multiple variations of this to no avail. Any ideas for what to do in this situation?
|
Cron on Ubuntu AWS with Python/Anaconda Virtual Environment
|
What is the version ofwgetyou are using? The exit status section for man page of version 1.15 says:In versions of Wget prior to 1.12, Wget's exit status tended to be unhelpful and inconsistent. Recursive downloads would virtually always return 0 (success), regardless of any issues encountered, and non-recursive fetches only returned the status corresponding to the most recently-attempted download.
|
I am writing a script which fetches some important data (via cronjob) from a url and sends an email if it failed, however, it doesn't seem to be recognising whether it failed or not (checking wget's return value [if]):wget_output=$(wget --tries=1 --timeout=300 -r -N -nd -np --reject=html https://myurl/ -P ../data)
if [ $? -ne 0 ]
then
echo "send email here" >> ./test.txt
else
echo "send email here" >> ./test2.txt
fiIt just tries 1 time (as told) and then gives up, but doesn't recognise that it has either succeeded or not. I'm presuming I'm not handling the exit code correctly or something. Any idea? Thanks
|
Send an email if wget fails
|
Yes, cron stops running when you turn off the computer. Everything stops running when there is no power. One option for persistent computing is to run a EC2 instance on Amazon Web Services. There is one instance type that is free (up to a point I believe). Other cloud computing services such as MS Azure are also an option.
|
I am planning out a script that I would like to write that will check a website everyday at midnight and do what is needed based off the users input. I will be posting this script online so other people can use it.However, I want the script to be able to continue running even when the users computer is off. Is there some place (I/the user) can host the script so that even when I/they turn off their computer it continues to run?The immediate idea that comes to my head or hosting it on a server of some sort. Is that possible?I have also been reading about cron. However, it appears that will stop working after the user has turned off their computer.Any tips or advice is appreciated.
|
Where can I host a script to run continuously?
|
I think whats happening is thecwdis not what you are expecting it to be. Try an explicitcdto a directory where you want the file to be createdSHELL=/bin/bash
* * * * * cd /root/Desktop; /root/Desktop/New.py
|
I add this line to crontab -e* * * * * /root/Desktop/New.pyThe New.py code is simple creating a text file here is the code of it#!/usr/bin/python
f= open("test.txt",'w')
f.write("test")
f.close()when I test executing the code using the shell it works correctly and when I tested the Cron using echo to a text file the Cron also works correctly, and I set the python file permission to executable, But still it doesn't work
|
Running python script using Cron in Beagelbone black
|
For every second use * * * * * ?.You can validate using Quartz CronExpression API. Just write a small Test using this method:org.quartz.CronExpression.isValidExpression(value);Hope it helps.
|
I am talking about theQuartz schedulerhaving 6 values viz seconds,minutes,hours,day-of-month,month and day-of-week. The optional 7th field year is skipped. In that case, is this a valid cronjob? Is it supposed to run every second from initiated?Second part of question: Is there any Cron validator available online? I have found some, but they are based on Linux Cron Jobs. I was looking for a Quartz Cron validator (Which is having an additionalsecondsparameter compared to Linux).
|
Is * * * * * ? a valid Cron Job?
|
TheFatal error: Cannot instantiate non-existent classerror message was shown bygood old PHP/4. ThePDOclass requires PHP/5.1.0 or greater. You simply cannot use such an outdated interpreter to run anything that resembles modern code.Hopefully, your hosting provider might have a newer interpreter available if you provide the appropriate full path, so you could replace this:*/10 * * * * php /homepages/9/d526231279/htdocs/cupidmemories/cronjobs/users.cron.php... with e.g. this:*/10 * * * * /opt/php5.6/bin/php /homepages/9/d526231279/htdocs/cupidmemories/cronjobs/users.cron.php(These are fake paths, don't just copy them expecting to work.)
|
I'm trying to make a cron job to delete any users that have deactivated their accounts a year ago, the script works on the website but when doing it through a cron job, I get a fatal error.Fatal error: Cannot instantiate non-existent class: pdo in /homepages/9/d526231279/htdocs/cupidmemories/cronjobs/users.cron.php on line 2Here is myusers.cron.phpfile:<?php
$db = new PDO('mysql:host=dbhost.com:port; dbname=dbname;', 'user', 'pass');
$query = "DELETE FROM users WHERE account_deleted='4'";
$db->query($query);
?>
|
Cannot connect to MySQL Database with Cron job
|
You could try30 12 * * * python /home/pi/Python/Email.pyor change permission of your file:chmod +x /home/pi/Python/Email.py
|
I'm just getting to grips with Python and Cron (and Raspberry Pi).I've written a script that sends me an email that I plan to have send me stats about my website on a daily basis. The script works fine, if I load it up in Idle and hit F5, I get an email.I've tried to get this to work in Cron, I've tried using command line and with the Gnome program but it doesn't do anything - I think I might have something wrong with the Cron command...30 12 * * * /home/pi/Python/Email.pyshould this work or have I missed something?
|
execute Python script with Cron
|
The-in front ofdeletepredicate is not generic dash (ASCII 45).How did i find it:Well, usingod:Your one:$ od -c <<<"find . -maxdepth 1 -name 'somelog*.log' -mtime +7 –delete"
0000000 f i n d . - m a x d e p t h
0000020 1 - n a m e ' s o m e l o
0000040 g * . l o g ' - m t i m e +
0000060 7 342 200 223 d e l e t e \nCorrect one:$ od -c <<<"find . -maxdepth 1 -name 'somelog*.log' -mtime +7 -delete"
0000000 f i n d . - m a x d e p t h
0000020 1 - n a m e ' s o m e l o
0000040 g * . l o g ' - m t i m e +
0000060 7 - d e l e t e \n
0000072
|
I am having some difficulties with cron and bash,mostly bash.There's a script that contains:#!/bin/bash
cd somefolder/
find . -maxdepth 1 -name 'somelog*.log' -mtime +7 –deleteand I added a cronjob for running this script:40 9 * * * /script-location/script.shbut it seems like I the job is not getting completed and not even running the command by hand is not being successful:find: paths must precede expression: –delete
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]Any ideas why or any advices in this case?
|
Find command expression error
|
The correct way is5 */4 * * * commandThat mean the job will run on minute: 5 of every 4 hours
|
This question already has answers here:How to do a cron job every 72 minutes(7 answers)Closed7 years ago.How to run cron every245 minutes?*/5 */4 * * * command- this variant is true?Or need to run?*/5 4 * * * command
|
Run cron every 245 minutes [duplicate]
|
Without cronjobs you could use a PHP class to shedule your tasks. Something like the PHP-Deamon from Shane Harter.https://github.com/shaneharter/PHP-Daemon
|
I have a situation where user defines when he wants his notification to be sent.What I need to do is to make that happen, but withoutCron job. I thought something like :while(true){
//something that is checking which time is it now and comparing desired time
//code for sending notifications(already got it)
sleep(3)
}So, infinite loop that is always checking current time and has pause for 3 seconds.I wonder if it is possible doing it like this or is there a better way? I have never done something like this, so please help.
|
Sending notifications on exact time in future via PHP without using Cron
|
Try:sed '/[^-A-Za-z0-9.\x27 ]/d;/''/d;/^\s*$/d' playlist.txt > cleaned_playlist.txtInput text:A goat
232423
-sdf-g
Here it goes
'keep me
$ let it go
\ this one tooOutput:A goat
232423
-sdf-g
Here it goes
'keep me
|
This is baffling to me, please help :-)I have a program which sometimes runs by CLI, and sometimes though cron, both as the same user, and both in the bash.In cron I useSHELL=/bin/bashto force bash.The offending command within the script is:egrep -v "$^" playlist.txt | egrep -v "[^ -.[:alnum:]]" >>formattedPlaylist.txtBasically, it should remove all blank lines from the playlist, then remove any line which contains anything other than [A-Za-z0-9 - .].For some reason, when run as a user from cli, this does not filter out many characters, whereas if cron runs it, it works exactly as expected.The characters which are not filtered out are:% $ # ! * & ( ) 'Any ideas??
|
egrep - regex filtering characters only working when run via cron?
|
does the cron run with the same user and privileges as you do?
is the bash the same? check php version...that was the problems on my server...
|
I have commandlog:demoand I successfully run it from ssh console with command:php artisan log:demo.Now I need to create cron job and its ok but when cron starts a command I get in laravel.log:> [2016-03-22 21:45:01] local.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/agroagro/public_html/vendor/symfony/console/Input/ArgvInput.php:283
Stack trace:
#0 /home/agroagro/public_html/vendor/symfony/console/Input/ArgvInput.php(283): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/agroagro/...', 283, Array)
#1 /home/agroagro/public_html/vendor/symfony/console/Application.php(790): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array)
#2 /home/agroagro/public_html/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/agroagro/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/agroagro/public_html/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}Why does manually calling command work, but cron does not?
|
Laravel schedule command with cron
|
You need to map your plugin function to an action, and then schedule that action to the Wordpress cron.// ---- Schedule cron event for custom plugin function.
add_action('init', 'custom_plugin_function_event');
function custom_plugin_function_event() {
if (wp_next_scheduled('custom_plugin_action') == false) {
wp_schedule_event(time(), 'daily', 'custom_plugin_action');
}
add_action('custom_plugin_action', 'custom_plugin_function');
}
// ---- Execute custom plugin function.
function custom_plugin_function() {
// Do something here
}The above example is for procedural code. replacecustom_plugin_function()with your plugin function's name.
|
I am devloping a custom plugin for woocommerce. In that plugin the functionality is like it will get all the users and send them email in every 24 hrs. So doing a work in every 24hrs even without visiting a site I think I need a cron job for that.
So by googling over wordpress cron job I gotwp_schedule_eventfunction. But here I
can't understand how to work with it? I mean how the function will work
here? I have my custom function to get all the users and send them email but how
to work that function withwp_schedule_eventand how thewp_schedule_eventfunction should be call
from the plugin so that if no one even visits the site it will work silently.
Any help and suggestion will be really appreciable. Thanks
|
How to use wordpress cron job with a custom function from the plugin?
|
This timespec would run your job on the 25th and 55th minute of every hour, every day:25,55 * * * *
|
I have one spring job to run every 30 minutes:-
Suppose current time is 1:55 pm, now it should run at 2:25 pm, 2:55pm, 3:25 pm & so on.This cron expression is not working for me:-
"0 0/30 * * * ?"
|
Cron expression running every 30 mins
|
Solved my issue. The cron job needed the absolute path of supervisorctl to properly execute the task (probably an issue of the environment the cron is using on execution)The working command is:#Ansible: daily restart of test_consumer
0 20 * * * root /usr/local/bin/supervisorctl restart test_consumerThe consumer is now properly restarted by the cron.
|
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.Closed4 years ago.Improve this questionI have a server running and using supervisor as process manager for my consumers.
Additionally I want to have a /etc/cron.d/restart_consumers file which executes daily.The restart_consumers file looks like that:#Ansible: daily restart of test_consumer
0 20 * * * root supervisorctl restart test_consumerWhen I usesudo supervisorctl restart test_consumerit says stopping and starting and in thesupervisorctl statusoutput I can see an uptime of a few seconds.When the Cron runs at 8 pm the running time of test_consumer is over a day. So it did not execute.If I set cron log level to 1 I get the following entry in the log file which looks fine:2016-03-09T20:00:01.377430+00:00 localhost /USR/SBIN/CRON[4762]: (root) CMD (supervisorctl restart test_consumer)can anyone tell me how I get my cron to restart supervisor processes?Restarting cron service did not help.Thanks in advance and if you need any more information feel free to ask.
|
Cron Job Fails restarting Supervisor Process [closed]
|
This is not explicitly named, but there are two general schools of thought in Chef resource design: "managed resources" vs. "managed collections". With a managed collection, you are convergently defining the entire state of the collection rather than a single object within it. This collection approach seems to be the one you are looking for, but it is generally avoided by the Chef community (and all core code) because it is extremely error-prone. There are a lot of reasons an object might not be visible within the Chef run (partial runs, composite runs, etc) and as the saying goes "absence of evidence is not evidence of absence". That said, some users (Facebook) have used the collections pattern to great effect thanks to heavy code review and training about the pitfalls. Check out thehttps://github.com/nvwls/zapcookbook for an implementation of azap_crontabresource that might fit your needs.
|
I would like to set my crontab in a convergent way using Chef. That is, I'd like to specify a list of cronjobs in my cookbook, and have Chef modify my crontab so that it includes only those entries, creating and deleting lines from the crontab as necessary.How can I do this?The built-incronresource doesn't seem fit for the task; its resources are individual cron jobs, and take either a:createor:deleteaction; I can't have it automatically remove entries from the crontab when I remove them from my cookbook unless I explicitly include a:deleteaction, and I don't want to have to list:deleteactions for every crontab I've removed from my cookbook throughout history.Thecroncookbookfrom the Chef Supermarket seems unlikely to solve this problem either, since it claims to support the same interface as the built-incronresource.
|
Convergently configure crontab with Chef
|
what about this?('* * * * *', 'tweets.cron.get_tweets', ['username'])--->docs<---
|
CRONJOBS = [('* * * * *', 'tweets.cron.get_tweets')]I can't add any parameter to this function and it doesn't work since it requires parameters.
I wanna add something likeget_tweets(username)
|
How to add parameters to function used in django cron jobs? (django-crontab)
|
If you must.. you could...update scoreboard
set points = case when ID = 2500 then '23'
when Id = 'XXXX' then 'YY'
when ID = 'YYYY' then 'XX' end
where ID in (2500,'XXXX','YYYY')But single updates make more sense here. You could write the a bulk insert to a temp table and update from that table if you have a thousands of records to update with different values. This may be faster.
|
So I run this php script as cron jobs updating points for users on scoreboard.<?php
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE scoreboard SET points='23' WHERE id=2500";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>This works fine for only oneidat a time. How can I edit 3id's with different points each? Thanks.
|
Update Mysql with more than one edit
|
Cron jobs have to be "created" withcrontab -eUse an absolute path for the specified command and not a relative path. Also make sure all commands called in the script are found regarding the general PATH setting or address them absolute as well.
|
Cron job execution on terminal */5 * * * * ./executeFiles.kshFacing this exception:sri@Inspiron-3521:~/Desktop/JAVA$ */5 * * * * ./executeFiles.ksh
bash: */5: No such file or directoryI am trying to execute this script every 5 minutes, and when I passed the command as */5 * * * * ./executeFiles.ksh
It says bash: */5: No such file or directory.
|
Cron job execution on terminal */5 * * * * ./executeFiles.ksh
|
A file on disk doesn't have query parameters. Query parameters are only used inURLs, which are irrelevant when executing a local file on the command line.Your invocation needs to look more like:php path/to/sub-crons.php 1Inside the script you need to use$argv[1]to retrieve the parameter instead of$_GET.
|
I have one cron file with namecron.php.
Inside it I'm usingcurl_multiapproach to start sub parallel tasks.Example:
The crontab of cpanel will execute this every minute.curl http://mywebsite.com/cron.phpInsidecron.phpI havecurl_multicode that call another file calledsub-crons.php. The first one will behttp://mywebsite.com/sub-crons.php?cron_key=1, second will behttp://mywebsite.com/sub-crons.php?cron_key=2and so on.And this is the problem, I want use the php command like this:php /path/to/my/cron.phpI can do that with the firstcron.phpfile but it will call the other file (for sub tasks in url and I want it to call it in PHPpath/to/sub-crons.php?cron_key=1).Can I do that?
|
Change a cron job from calling via url (curl) to calling via local command line (PHP)
|
You can use a singleupdatewithjoinfor this:UPDATE user u JOIN
(SELECT COUNT(`user_to`) AS fav_count, user_to
FROM `users_favorite`
GROUP BY `user_to`
) uf
ON uf.user_to = u.user_id
set u.fav_count = uf.fav_count;You might want to consider a trigger to maintain the count in the summary table, if you want it kept up-to-date. That would be a re-design of this component of your system, however.
|
I have following running on php-cron job as php-script. I would like to know is there a possibility that i can do the same thing in ONE MySQL query on the fly ?$sql = "SELECT COUNT(`user_to`) AS fav_count , user_to FROM `users_favorite` WHERE 1 GROUP BY `user_to` ";
$result = mysql_query($sql, $db) or die("Error in query:" . mysql_error());
while ($row = mysql_fetch_array($result)) {
$fav_count = $row['fav_count'];
$user_id = $row['user_to'];
$sql1 = "UPDATE user SET fav_count='" . $fav_count . "'
WHERE user_id=" . $user_id . " ";
$result1 = mysql_query($sql1, $db) or die("Error in query:" . mysql_error());
}
|
MySQL combine PHP cron job SQL's into One Query is it Possible?
|
For example:wget -q -O - "http://example.com/xx/file.php" > /dev/null 2>&1
|
How can i add my file of php and txt in cron job of 10 mint for example
my url is :http://example.com/xx/file.phpandhttp://example.com/xx/file.txtand I'm try this command wgethttp://example.com/xx/file.phpwhen i add this command panel email me in spam of error.
|
How to i add CRON Job in Vesta CP Pannel What is Command
|
Got it by running the below script:for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; doneIt showed all the cron jobs listed by all users
|
ON my production server every saturday weekly emailer task starts and we all start getting emails. However I am not able to figure out where this cron job is set on my server or in my php joomla code.I have checked crontab -e output and its like as below:# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow commandas everything here is commneted I presume there is cron job placed.Please let me know what all should I look into so that I can get to know how this weekly emailer is being triggered. Any kind of help is appreciated !!
|
looking for a cron / scheduler job on my production server
|
If you have root on the system.If you have a distro with systemd.then...You can use systemd to restart a process as soon as it ends using "Restart=always". For example:[Unit]
Description=My cool service
After=network.target
[Service]
ExecStart=/usr/local/sbin/myservice
User=<myuser>
Group=<mygroup>
Restart=always
[Install]
WantedBy=multi-user.target
|
Say I have this sh script to monitor my python script and restart it if it crashes:until myserver; do
echo "Server 'myserver' crashed with exit code $?. Respawning.." >&2
sleep 1
doneWhile it might work well for a python script which is supposed to do some workand exit, it won't for my case because I need my python scripts(a few ones, not only one) toalways work 24/7in background. And if one of them ever exists that means it's crashed and should be restarted.How should I handle my case?
|
How to restart the python scrypts regardless of the reasons they've existed or crashed?
|
Changecron.txtby full path/var/www/my_system/cron.txt// /var/www/cron.php
$myfile = fopen("/var/www/my_system/cron.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);Or move to directory:chdir("/var/www/my_system");
$myfile = fopen("cron.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);And try again.
|
How can I run a cron task in Linux?Following thisQ&A,I have this cron task to run - just writing some info to a txt file,// /var/www/cron.php
$myfile = fopen("cron.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);But after adding the cron task via my terminal,crontab -eand then,* * * * * /usr/bin/php /var/www/cron.php &> /dev/nullBut when I open cron.txt, there is nothing in it.Why? What have I missed?
|
Linux cron task - how to add and run a cron task?
|
You can override the default template for jobs like this:set :job_template, "TZ=\"Europe/London\" bash -l -c ':job'"
|
I am using whenever gem + capistrano to automate my cronjob generation whenever I deploy my app to the live server. Currently the cron that being generated by whenever looks like this(without the timezone "TZ") :30 20 * * * /bin/bash -l -c 'cd /home/deploy/apps/myapp/releases/20160123202716 && RAILS_ENV=production bundle exec rake overdue_payments --silent >> /home/deploy/apps/myapp/releases/20160123202716/log/cron.log 2>&1'My question is, how do I make whenever generate this line together with the timezone (TZ="Europe/London"), so that it will looks like this:30 20 * * * TZ="Europe/London" /bin/bash -l -c 'cd /home/deploy/apps/myapp/releases/20160123202716 && RAILS_ENV=production bundle exec rake overdue_payments --silent >> /home/deploy/apps/myapp/releases/20160123202716/log/cron.log 2>&1'Hope somebody could help..thanks! :)
|
How to set Timezone on whenever gem cronjob
|
try* * * * * php /var/www/html/email.phpotherwise, cron tries to execute the command "root", which is not a command.
|
I hava a php-email (phpmailer 5.2.14) script which work fine when I run it in bash:pi@schnickschnack: php /var/www/html/email.phpwhen i run this script with cron (sudo crontab -e):*/1 * * * * root php /var/www/html/email.phpsyslog says...Jan 22 08:53:01 Schnickschnack CRON[4482]: (root) CMD (root php /var/www/html/email.php)...but I get no mail.
I have another php-script which works fine with crontab. this script inserts values from phpmodbus into a mysql-db...
does anyone have a hint why the mail-script does not work with cron?
|
run php-script with cron does not work
|
You seem to have fixed the invalid hour issue, now if your php script is accessible via the web, why don't you use acurlrequest as your command?0 16 * * 4 curl --request GET 'http://www.yoursite.com/path/to/myscript.php'Obviously you'd need to secure it, probably with a custom get key or even in.htaccess, only allowing server access.
|
I want to push mycron.txtto crontab using something like:crontab cron.txtThe contents of my cron.txt file are:# Format : minute | hour | day-of-month | month | day-of-week | path-to-script
0 1600 * * 4 C:/path/to/myscript.phpI am getting the error:"cron.txt":4: bad hourHow can I run the script properly? Is all that is needed the time and the path to php file?Thanks.
|
Running a PHP Script with Cron From Cygwin
|
You can't use the crontab on heroku, you have to use something like theHeroku Scheduler.The reason why you can't use the crontab is that heroku uses an ephemeral file system. So, if you run a command to change the crontab (withheroku run whenever --update-crontabfor example), heroku would start a dyno, change its crontab locally, then throw the dyno away. So your changes would not be persistent.You can use theHeroku Schedulerwith a free account, you just need to write your code as rake tasks, then add the corresponding rake commands in the scheduler config page.
|
I am usingwhenevergem for cronjobs. To update crontab locally I dowhenever --update-crontabI want to know how to update cron-tab on heroku.Another question is that I am using free-tier of heroku.Is paid account needed for that or not?
|
How to update crontab in heroku
|
Ok, so 7 months later I've come back to this cron issue. It turns out that theupload2youtube.pyexample file was hardcoded to look in the current directory for theclients_secrets.jsonfile. This explains why I could run it manually from the local directory but not on cron. I've included the full path in the example file and this works fine now.
|
I am trying to upload a video to YouTube each afternoon using the sample YouTube Python upload script from Google (see Python code examples on developers.google, I haven't enough reputation to post more links...). I would like to run it as a cronjob. I have created the client_secrets.json file and tested the script manually. It works fine when I run it manually, however when I run the script as a cronjob I get the following error:To make this sample run you will need to populate the
client_secrets.json file found at:/usr/local/cron/scripts/client_secrets.jsonwith information from the Developers Consolehttps://console.developers.google.com/For more information about the client_secrets.json file format, please
visit:https://developers.google.com/api-client-library/python/guide/aaa_client_secretsI've included the information in the JSON file already and the -oauth2.json file is also present in /usr/local/cron/scripts.Is the issue because the cronjob is running the script as root and somehow the credentials in one of those two files are no longer valid? Any ideas how I can enable the upload with cron?Cheers
James
|
Authentication issue when uploading video to YouTube using YouTube API and cron
|
You can see if the user has the permission byls -l /var/www/other/notif.phpIf it shows -rw-rw-r-- that means the current user has only read and write permissionJust the give the permission by runningchmod +x /var/www/other/notif.phpAfter changing the permission it would show something -rwxrwxr-xBy the way in recent version of Ubuntu the default directory is /var/www/html for apache, make sure your path is correct if it is required run by apache.
|
I have a problem with cronjob. I read many guides and questions about the same problem and did it the same way as its described there (example) but it is still not working.Here is the line from the crontab file:*/5 * * * * /usr/bin/php /var/www/other/notif.php
|
Ubuntu linux apache2 cronjob not calling php files
|
Update:add the following permission to my script solved my problem(get it from env)export XAUTHORITY=/home/vitidn/.Xauthority
|
I have the following script(/home/vitidn/Downloads/adjust_contrast.sh) to adjust display contrast:#!/bin/sh
export DISPLAY=":0"
echo "adjust the display..."
xrandr --display :0 --output eDP1 --prop --verbose --gamma 0.5:0.5:0.45it works fine if I run from cmd line but failed to run from crontabIt also has all perms:-rwxrwxrwx 1 root root 167 Jan 8 10:04 /home/vitidn/Downloads/adjust_contrast.shI create a crontab(with sudo) with the following content:* * * * * /home/vitidn/Downloads/adjust_contrast.sh > /tmp/adjust_contrast.outputIn /tmp/adjust_contrast.output, the script is run accordingly but part of xrandr otuput is no where to be found:adjust the display...I suspect that it has somethings to do with a permission but still can't pinpoint it.Thank you for your helps
|
Can't execute xrandr command in crontab(even with $DISPLAY arg supplied)
|
When you typesh ocrmypdfyou ask theshshell (probably/bin/shwhich is often a symlink to/bin/bashor/bin/dash) to interpret theocrmypdffile which is aPythonscript, not a shell one.So either runpython ocrmypdforpython $(which ocrmypdf)or make theocrmypdfscript executable. Then (on Linux at least)execve(2)willstart the python interpreter, because of theshebang.Of course, theocrmypdfscript should be in yourPATHAndcrontabjobs are not running in your desktop environment. So they don't have access to yourX11serverXorg(or toWayland, if you are using it). You could explicitly set theDISPLAYvariable for that, but I don't recommend doing this.
|
I try to start a python program called ocrmypdf from a script or as a cronjob.It works perfectly from the terminal,pi@piscan:~ $ ocrmypdf
usage: ocrmypdf [-h] [--verbose [VERBOSE]] [--version] [-L FILE] [-j N] [-n]
[--flowchart FILE] [-l LANGUAGE] [--title TITLE]
[--author AUTHOR] [--subject SUBJECT] [--keywords KEYWORDS]
[-d] [-c] [-i] [--oversample DPI] [-f] [-s]
[--skip-big MPixels] [--tesseract-config TESSERACT_CONFIG]
[--pdf-renderer {auto,tesseract,hocr}]
[--tesseract-timeout TESSERACT_TIMEOUT] [-k] [-g]
input_file output_file
ocrmypdf: error: the following arguments are required: input_file, output_filebut from another shell it breaks for reasons I do not understand.pi@piscan:~ $ sh ocrmypdf
sh: 0: Can't open ocrmypdf
pi@piscan:~ $ which ocrmypdf
/usr/local/bin/ocrmypdf
pi@piscan:~ $ sh $(which ocrmypdf)
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
import: unable to open X server `' @ error/import.c/ImportImageCommand/364.
from: can't read /var/mail/ocrmypdf.main
/usr/local/bin/ocrmypdf: 10: /usr/local/bin/ocrmypdf: Syntax error: "(" unexpected (expecting "then")This is the executed code:pi@piscan:~ $ cat $(which ocrmypdf)
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from ocrmypdf.main import run_pipeline
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pipeline())
|
Not able to start python program via sh / crontab
|
Use*/15for minutes:0 */15 * * * *
|
I'm trying to come up with a schedule for my Azure WebJob in crontab format that will run every 15 minutes but exactly at h:00, h:15, h:30 and h:45.The one that I'm using for my web job right now is:{ "schedule": "0 0/15 * * * *" }But this doesn't make it run exactly at the top of the hour then every 15 minutes thereafter.I want the job to keep running -- no end date/time. However, when I launch the webjob, it should not start running until it's h:00, h:15, h:30 or h:45 -- whichever happens to be next. For example, if I deploy my webJob at 8:37 AM, the first run should be at 8:45 AM AND it should then keep running every 15 minutes after that.I'd appreciate some help with this. Thanks.
|
WebJob Crontab schedule running at the top of the hour and every 15 min thereafter
|
You're trying to echo Javascript before the page is loaded. Thewp_schedule_single_eventfunction will fire before the template is displayed, so you will have your<script>tag echo'ed before your doctype. Besides that, if someone else visit your website at the moment the event is scheduled he'll get the alert (if it would be echo'ed at the right place), not you.If you just want to test your cron executions I suggest to log executions in some file on your server instead.I know this will schedule events every time I load a page from my site
and I also need to put at-least a 10min gap between scheduling events
with the same name, I read the doc ;-).That's not quite right, you'll stack events in your crontab every time page is load,butthey will be executedfrom15 seconds of the schedule time. That means one user could have multiple events firing on the same load.As example:00:00:01 : User visit > Schedule event 1
00:00:02 : User visit > Schedule event 2
00:00:03 : User visit > Schedule event 3
[... no one visit your website in a minute ...]
00:01:00 : Execute events 1, 2 and 3, and schedule event 4
|
I am practicing the schedule events of WordPress. I am writing a function that will show me an alert right after 15s of the time the event was scheduled. I ended up with the following code.function do_this_in_time() {
echo "<script>alert('');</script>";
}
add_action('my_hook_in_time','do_this_in_time');
wp_schedule_single_event( time() + 15, 'my_hook_in_time');I know this will schedule events every time I load a page from my site and I also need to put at-least a 10min gap between scheduling events with the same name, I read the doc ;-).So Let's say I just loaded the page only one time. But I am still not getting the alert.I also have checked the scheduled events using_get_cron_array()and I can see my event scheduled as follow.[1449843473] => Array
(
[my_hook_in_time] => Array
(
[40cd750bba9870f18aada2478b24840a] => Array
(
[schedule] =>
[args] => Array
(
)
)
)
)But it seems it is not firing off. What am I doing wrong here?
|
wp_schedule_single_event registers a cron but won't fire the function
|
Could be an environment problem. Cron jobs are run with an extremely limited set of environment variables and they won't read your bash_profile or any other startup files. Even PATH may not be set. To verify this, run$ env -i HOME=$HOME /path/to/scriptfrom your terminal's command line prompt. If this can't run ("command not found"), addPATH=$(/usr/bin/getconf PATH)at the start of your script, then try again. Set all variables needed by the script in the script itself.
|
Background:I'm usingSassfor CSS compilation with Bootstrap 3.Created agulp taskto trigger the compilation. 'gulp style'Got tired of executing thegulp styletask every time I make a change to the scss file.Found out about crontab. Created my cron-file.txt to execute a bash file every 30 secs. Answer Courtesy :Running a cron every 30 seconds* * * * * /bin/bash -l -c "/my/path/autogulp.sh; sleep 30 ; /my/path/autogulp.sh"autogulp.sh Contentscd ~
cd /my/path/
gulp styleI tried running the commandsmanuallyand they seem to beworking fine. Had to change the R/W mode for the cron-file.txt and autogulp.sh.
But my objective isn't fulfilled yet. The'gulp style' isn't working automatically every 30 secs.I tried routing the std and error output to a file but the contents of the file are always empty.
|
How can we verify if a crontab job is running?
|
Yes, you can achieve this using cron job. Wrap up the execution of the pig script with its relevant configurations and parameters in a unix script. Just schedule the script from crontab.
The execution command will bepig (arguments) (script)
|
I have a pig script which I want to automatically execute every week on a hadoop cluster.
Can I use a cron job to do this? How can I execute this solution? please help
|
Running pig script every week on hadoop
|
I confirm that even thelatest git for windows(2.6.3) with its 4.3.42(3)-bash does not include any cron command.You would need to useanother "cron from Windows", like the official Microsoft commandSchtasks.exe.
|
I cannot usecrontab -ein my git that I installed it in my pc windows 7. It produced the errorbash: crontab: command not foundDid someone use to do it, please tell me?
|
crontab command not found in my git-bash for windows 7
|
I had the similar issue as you're doing. My backup script was working very well if it's called directly but wasn't working in crontab at all. I figured it out by adding this in the start (after shebang) of bash script:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/optWhere "/opt" in the last is the directory where my bash script exists.
|
i have move_files.sh and installed it in crontab.Actually job is working because it's printing those echo. And creating log file.
But it's not calling that PHP script.
Interesting thing is if i run it by manually it's calling php script and working 100%. But why it's not calling after i installed it on crontab.
should i put "php" before calling php script. I am thinking that cronjob would work same as manually running script. Please give me idea.My code is below.#!/usr/local/bin/bash
DIR=/data/aa/bb
LOG=~account/HOME/log/dd
DATE=`date +%Y%m%d`
LOG_FILE=$LOG/move_files.$DATE.log
PROG=~account/HOME/bin/move_files.php
for type in "1" "2" "3"
do
echo "Check files in $DIR/dat/$type" >> $LOG_FILE
$PROG $DIR/dat/$type $DIR/backup/$type >> $LOG_FILE
echo "Compress files in $type" >> $LOG_FILE
find $DIR/backup -name "*.DAT" -type f -exec gzip -f {} \; >> $LOG_FILE
done
|
not calling php script from shell script which installed in crontab
|
Usecrontab's-uoption. Theman pagesays:-uAppends the name of the user whose crontab is to be modified.
If this option is not used, crontab examines "your" crontab,
i.e., the crontab of the person executing the command. Note
that su(8) may confuse crontab, thus, when executing commands
under su(8) you should always use the -u option. If no
crontab exists for a particular user, it is created for him
the first time the crontab -u command is used under his
username.So the correct command is:sudo crontab -e -u oracle
|
I am attempting to run a script through crontab that is required to run as anoracleuser. I have tried creating a crontab for that user by:su -u oracle crontab -ewhich has allowed me to create one. I edited the file to run a perl script:0 5 * * * /usr/bin/perl /path/master.pl > /tmp/debug.logHowever when the time passes nothing is run.
Is this the proper way to create a crontab for non-root user? Also the master.pl file call multiple scripts that also need to be done as a oracle user if that makes a difference.
|
Creating crontab for non-root user
|
Enter to thecpaneland go toHome » Server Configuration » Configure cPanel Cron JobsEnter the following values:Minute:*/5Hour:*Day:*Month:*Weekday:*In theCommandtext box enter:rm -rf /home/Name/public_html/Folder/*.exeThe following steps are equivalent to crontab field:*/5 * * * * rm -rf /home/Name/public_html/Folder/*.exe
|
Ok so I need to make a cronjob that will delete all the .exe files from a specific directory in my cpanel account.
my home folder is "/home/Name"
the folder that contains the .exe files located at "/home/Name/public_html/Folder"
I'd like to set it to delete all the .exe files there every x min, say 5 mins.
Thanks a lot in advance.
|
Cronjob to delete specific files by extension after x mins
|
Try this:0,5,10,15,20,25,30,35,40,45,50,55 * * * * <Your command>
|
I am running a cron job which will run at every 5 minutes.Now Let's say i have started job on 04:02 so it will execute at every 5 minutes so will execute on 04:07, 04:12, 04:17 etc...Let's say i have started job on 13:18 so it will executed at 13:23, 13:28, 13:33 etc...But what i want is it should only execute in multiplication of 5 minutes means if i create job on 04:02, it should start executing from 04:05, 04:10 and so on.And if start job on 13:18, it should start executing from 13:20, 13:25 and so on.So how to achieve this?
|
How to start cron jobs removing offset?
|
You have wrong crontab. What you specified is "run task at 15 minutes after each hour".You need this crontab to run task every 15 minutes:*/15 * * * * /usr/bin/mysqldump -u XXX-pXXX demobackupDB > /home/user/DBbackup/$(date +%F)_backup.sqlIf your job is still not running there could be many reasons of this.You can start debugging with the simple test like this:* * * * * echo hi >> /home/user/test(You should see a new line "hi" appended to/home/user/testfile once a minute)If this is not the case see probable reasons for ubuntu here:https://askubuntu.com/q/23009.Also see cron log:https://askubuntu.com/q/56683/103599
|
I am trying to backup my mysql database using linux crontab like below command,$crontab -e
15 * * * * /usr/bin/mysqldump -u XXX-pXXX demobackupDB > /home/user/DBbackup/$(date +%F)_backup.sqlBut i dont find that .sql file in the specific folder after every 15 mins.How to find what is error and fix it?
|
Cron job not running to backup mysql database
|
with help from RC's comment. I came up with this. This will return the difference in days.String cron = "0 0 12 * * ? *";
CronExpression cronExpression = new CronExpression(cron);
Date date1 = cronExpression.getNextValidTimeAfter(new Date());
Date date2 = cronExpression.getNextValidTimeAfter(date1);
long diff = date2.getTime() - date1.getTime();
long days = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
|
Is there any easy way to do it other than comparing the characters in the cron expression with all the possible characters?
|
How do I check if a cron expression executes daily, weekly or monthly?
|
The first patterns will run your cronjob every 58th second: 00:00:58, 00:01:58, 00:02:58...and so on.The slash character can be used to identify periodic values. For example*/15 * * * * *means, that your job will run ever 15th second: 00:00:15, 00:00:30, 00:00:45 ...and so on.In my opinion*/58doesn't look very useful. This will execute every 58th second of every minute, so just use the first one.
|
I am usingnode-cron. Please help to explain to me the different between:var pattern_1 = '58 * * * * *';
var pattern_2 = '*/58 * * * * *';when running this function:new CronJob(pattern, function() {
console.log('lalalalala')
}, null, true, 'America/Los_Angeles');
|
time pattern in node-cronjob
|
You may not usescreenfor running things in background in a script. Use ampersand (&) to background a process andnohupso it won't be killed when cron script exits. Also remember a subprocess PID in a file.Something like this:kill -- "$(cat mybot.pid)"
now="$(date +%Y%m%d%H%M%S)"
nohup node mybot.js >> "logi/logi_$now.txt" &
echo $! > mybot.pid
|
I want to run the script every 30 minutes with cron but I have problem with my code.
In every 30 min I have to kill old script and run it again. I have somethink like this, but it is not working:cd /var/www/scripts
pkill -f bot
now="$(date +%Y%m%d%H%M%S)"
screen -S bot
node mybot.js >> logi/logi_$now.txt
|
run the script every 30 minutes bash
|
From the error message, you can see thatphpseclibis not being added to the include path correctly. Try this for the set_include_path instead:set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . DIRECTORY_SEPARATOR . 'phpspeclib');The__DIR__will take into account the location of the file you're executing, rather than trying to findphpspeclibrelative to the current working directory.
|
The file path for my script is/var/www/html/MyProject/index.phpwhen I run the script as~/./Myproject$ php index.phpits runs perfectlyWhen I run the script as~$ php /var/www/html/MyProject/index.phpIt does not read the phpseclib file pathMy index.php file is<?php
include("crud.php");
include("functions.php");
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SFTP.php');
...
?>error:PHP Warning: include(Net/SFTP.php): failed to open stream: No such file or directory in /var/www/html/MyProject/index.php on line 6
PHP Warning: include(): Failed opening 'Net/SFTP.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear.:/usr/share/php:/usr/share/pear/phpseclib') in /var/www/html/MyProject/index.php on line 6
PHP Fatal error: Class 'Net_SFTP' not found in /var/www/html/MyProject/index.php on line 186How to run the php script form cron job?
|
phpsec lib path is not working from cron job
|
Use synced-cron from the server, you'll be much happier sooner. If you do it from the client then you have to (a) ensure at least one client is up and running at midnight and (b) make sure it's the right client with the proper privileges and not all clients scraping everything.OTOH, if you want to distribute a job to multiple clients and have them all cooperate then that's a completely different proposition.Anywhere in/serveradd:SyncedCron.add({
name: 'Daily Scraper',
schedule: function(parser) {
return parser.text('every 1 day'); // parser is a later.parse object.
},
job: function() {
... your scraping code here
}
});SeeLater.jsfor details on how to create the schedule
|
I need to scrape data from certain websites at 12.00 AM PST, and present that scraped data on my website. How should I implement this? Will it be server-side or client-side? Should I usemeteor-synced-cron?I was thinking I'll do it withoutmeteor-synced-cron, and do it instead inclient/, in that if the time is 12.00 AM, I update my collection for once and for all. Is that the right approach?
|
Schedule scraping job - Meteor JS
|
You should create scheduled task that calls the script interpreter with the path to the script as an option. For example:/usr/bin/php /var/www/vhosts/domain.com/httpdocs/bdmail.phpinstead of just/var/www/vhosts/domain.com/httpdocs/bdmail.php
|
I am trying to set a cron job where it will run php script and mail the results to user. However I am getting a permission denied error when the script is run./bin/sh: /var/www/vhosts/domain.com/httpdocs/bdmail.php: Permission deniedThis is the code I am using in the command line:/var/www/vhosts/domain.com/httpdocs/bdmail.phpI would be grateful if someone could highlight my error. I have setup a new task in plesk and it looks correct to me. ThanksOS: CentOS 6 with Parallels Plesk Panel 12 (64-bit)
|
Plesk 12 scheduled task error
|
The crontab syntax is:mm hh dd mt wd. So to set it to every morning at 6am it would be00 06 * * *meaning 06:00 (24 hr time) of any day, month, weekday. If I'm referring to thedocumentationcorrectly, this should work:from crontab import CronTab
tab = CronTab()
cmd1 = 'actual command'
cron_job = tab.new(cmd)
cron_job.setall('00 06 * * *')
cron_job.enable()
tab.write_to_user(user=True)
|
from crontab import CronTab
tab = CronTab()
cmd1 = 'actual command'
cron_job = tab.new(cmd)
cron_job.minute.every(1)
cron_job.enable()
tab.write_to_user(user=True)I have tried using minute.at(1) to run at the first minute, but I don't know whats the right way to run the command at a fixed time (6 am), just once.. I know "every" ends up repeating it, but I don't want that. The caveat is I need to use python-crontab.
|
Running a cronjob only one using python-crontab
|
You should prepare a script to do the job (reset the value of a column). To run only once you can do this in your crontab:30 12 16 10 ? 2015 /scripts/resetThis will execute your script at 12:30 on October 16th this year.Anyway, your question has nothing to do with Laravel 4.2.
|
I'd like to run a job that will reset a value of a column lets say to 0 in a database after a month then remove the job after that. How will I able to do this in Laravel 4.2?
|
Laravel 4.2: Start a cron job after a month
|
All type of cron exrpession you build from website [Cron Maker]
I have one solution to meet with your requirement:
Algorithm:
1. Run cron every MON and WED day.
eg. 0 0 12 ? * MON,WED *
Start time Monday, September 7, 2015 6:10 AM Change
Next 5 scheduled dates
a. Monday, September 7, 2015 12:00 PM
b. Wednesday, September 9, 2015 12:00 PM
c. Monday, September 14, 2015 12:00 PM
d. Wednesday, September 16, 2015 12:00 PM
e. Monday, September 21, 2015 12:00 PM
2. Now pro-grammatically control on odd week. for eg in java
Calendar c = Calendar.getInstance();
if(c.get(Calendar.WEEK_OF_MONTH) % 2 != 0) {
//execute job
} else {
//not execute job just skip operation
}if i am able to made actual cron then i will post it.
|
I need to trigger my mail every alternate Monday and Wednesday. I am using Java Spring in my application. I have try using this cron expression00 15 11 ? * MONDAY#1and same for Wednesday, but it is triggering on 1 Monday and Wednesday of the month. What I want is it should trigger on Monday and Wednesday of first, third and fifth week of each month.Can someone please help me in creating this cron expression.
|
Cron Expression recurring after every two week
|
I actually got it to work by modifying the refresh.sh withsudo -u pi screen -d -m export DISPLAY=:0 && xdotool search "Chromium" windowactivate --sync key F5 > /dev/null 2>&1I guess the cronjob runs under a separate shell that when it tried to fetch the display with xdotool it wasn't able to. With this the cron job actually fires up a shell as the pi user and then executes the xdotool which then runs the command like it should and then once that command is done the screen session dies. Effectively doing exactly what I needed for the digital sign.
|
I have a raspberry pi set up to act as a signage system using a google presentation url as what its displaying. Problem is I need this page to be refreshed every 5 minutes to grab new information added or removed from the slideshow.What I had set up was a small cron job running every 5 minutes*/5 * * * * export DISPLAY=:0 && /bin/bash /home/pi/refresh.sh
[xdotool search “Chromium” windowactivate --sync key F5] <- Contents of refresh.shHowever as I have noticed from watching the display it is not auto refreshing and if I run that command manually from ssh it refreshes just fine.Does anybody have any tips? Maybe I'm missing something?
|
Raspberry Pi Refresh Browser
|
Are you able to select "Interval Minutes" of something like that instead of "Selected minutes"?Otherwise you have to select0, 5, 10, 15, 20, ... and 55in your select box. Multiselect should be possible.
|
I have a WordPress application which is hosted on DreamHost. I'm currently running a cron job under my DreamHost account which will visit a template every 5 minutes. The current cron time settings look something like this:I expect this cron job to execute every five minutes. However, it seems to be running every one hour, since I only get a report on my email address after every one hour.What seems to be wrong here?
|
Cron job not running at custom time setting
|
Crontab line is ok:*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.phpI think the problem with script.try to run it manualy:php /var/www/html/ulchemdb/File_upload/uploads/crontab.phpor if You don't have opportunity to get to console do following:enable error reportingadd line to then end of crontab.php:echo "\nCOMPLETED SUCCESSFULY\n"add this crontab line:*/5 * * * * php /var/www/html/ulchemdb/File_upload/uploads/crontab.php >> /var/www/html/ulchemdb/File_upload/uploads/crontab.logAlso You can share with us Your code, we'll try to help You somehow.
|
I have this code bellow to run in command line but is not working. I tried in command line to run without the cron tab and it works. Anyone knows how to fix it ? Thanks in advance.*/5 * * * * /usr/bin/php /var/www/html/ulchemdb/File_upload/uploads/crontab.php > /dev/null 2>&1
|
cron tab not working
|
In some cases uploading the app alone doesn't update the cron jobs, in such case you need to update the cron jobs specifically usingappcfg.py update_cron, seehttps://cloud.google.com/appengine/docs/python/config/cron#Python_app_yaml_Uploading_cron_jobs
|
I am creating cron job and it's work on the local dev sever (http://localhost:8000/cron).I uploaded application to google app engine, but I see "You have not created any scheduled tasks (cron jobs) for this application."My cron.yaml:cron:
- description: calc week raiting
url: /cron_everyhour
schedule: every 1 hoursMy app.yaml:application: w....
version: 1
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: django
version: "1.2"
handlers:
- url: /css
static_dir: css
- url: /images
static_dir: images
- url: /img
static_dir: img
- url: /js
static_dir: js
- url: /sound
static_dir: sound
- url: /swf
static_dir: swf
- url: /favicon\.ico
static_files: images/favicon.ico
upload: images/favicon\.ico
- url: /apple-touch-icon-precomposed.png
static_files: js/apple-touch-icon-precomposed.png
upload: js/apple-touch-icon-precomposed.png
- url: /apple-touch-icon.png
static_files: js/apple-touch-icon.png
upload: js/apple-touch-icon.png
- url: .*
script: main.APP
|
Python Google App Engine Cron Job Not Working
|
Try This,You need to run a php file through cron job.in your terminal...
user > crontab -e
0 * * * * /opt/lampp/bin/php -f /<absolute path of file>/cron_summary_sales.php< /opt/lampp/bin/php > this is PHP path, as I use LAMPP,
You use appropriate path for your PHP setup in your MAC. you also have to make sure how to run PHP from MAC terminal.save it.For mac,
I think you should do,0 * * * * php /<absolute path of file>/cron_summary_sales.php
OR
0 * * * * /<absolute path of dir> php cron_summary_sales.php
|
I am new tocronand I do not know how to work it and I have researched everywhere, but I am confusedI have a mysql database which is connected to php and it is on a website which is calledytable.php.Within that php file, I have a for loop which needs running every hour in order to retrieve new information. However, I am not sure what to do in order to do this.I know I have to write0 * * * *somewhere in the coding.Most of the answers on this website tells how the* * * * *work, but I am not interested intuit because I already understand that bit of thecronjob.Do you either:put the command in a text file and write<?php exec(whatevertextfile.txt) ?>in the file itself?OREveryone has been telling me to open up Terminal(Mac) and put it incrontab -e, but I do not know what to write when I get there.Can you not run a cron job from a php file as I find it easier to edit compared to Terminal.Please help.
|
How to run cron job on mysql database through php
|
First you should put the call to your PHP script inside a Shell script.In this script, the first step would be to count current running instances of your PHP program.If the count is below the defined limit (10in your case), run a new instance of your PHP program.Now about how to count the current running instances, you could achieve this using thepscommand piped with agrepcommand (to filter processes) followed by awc -lcommand (to do the counting).Or you could create a unique empty file just before running a new instance, like/tmp/php_script_<timestamp>and delete it when the PHP script is over.Counting instances would then be equivalent to counting the number of files in/tmpstarting withphp_script_(anothergreppiped withwc -l).
|
I have a php script that runs jobs on a server via cron. Basically the cron is run every minute like:php /path/to/my/script/script.phpThis script can be run multiple times, and continue to run for some time.What I am trying to do, is find a way to read the processes running for this user, and count how many times script.php is running. Before the cron is actually run. Basically so that if there are 10 instances of the script running, no other instances of it will start until there are less then 10 running. I need to make sure it doesn't start if there are 10 running.Hopefully this makes sense. ;)
|
Show Number of Times a PHP Script is Running via Cron
|
You will have to persist the value of the variable to a non-volatile source between calls to the script. Furthermore, you'll have to consider race conditions if (as is often the case) the script can be called at almost the same time.The best bet for this, is to store your variable in a database that maintains transactional safety. Even most cheap webhosters offer some form of database that will meet this requirement ... the specifics depend on your particular setup.
|
Is it possible to increment a variable or array by 1 each time the script is executed.An example would be, I execute the script and it sets a variable to$increment = '1';I then close the script and come back 30 min later to execute the script again.This time the variable needs to be$increment = '2';The script will be run from cron every 30 minutes for a total of 8 times.After the 8th execution the variable would need to be rewound back to$increment = '1';Is this possible through session? Can session be setup for the cli sapi ?Or would it be easier to output a text file with the next increment number and just pull the value from the text file?All help is appreciated.
|
PHP function to increment variable by 1 each time script is executed
|
you can edit a users crontab with -u.e.g. edit crontab for www-data:sudo crontab -u www-data -e
|
I try to run cronjob, which execute php script and which also is added from php script.I trying it on localhost. When php add cron, it is added as daemon user and job doen not execute. When I add the same cron as I or as root cron will execute. Is exist any perrmiosions for that?In cron logs, there are the same logs for daemon,I and root users, withour errors.In addition, when I add some other cron to daemon crontab for example:* * * * * touch tmp/test.txtthen it will be work, and file will be created.
I tried to change permiossions for files, but it not solved problem.
What could be the reason of that?
|
PHP Cronjob on different users
|
You are completely correct. If you would like, you can remove your leading zeroes from your first two numbers like this:0 1 1-7 * 1 test.shYou can read all about cron syntaxhere. To the best of my knowledge, Jenkins uses cron style formats but simply enhances it capabilities.
|
I want to execute a job in Jenkins at 1.00 am on first Monday of every month.00 01 1-7 * 1Is this correct? Though i verified it using below link. Still not very sure.test link
|
Cron expression for jenkins Job
|
You are probably using a version of ioncube that doesn't match your php version. Connect to your server using SSH and run this:cd /usr/local/directadmin/custombuild
./build update
./build clean
./build set ioncube yes
./build ioncube
service httpd restart
|
I am using cron jobs in DirectAdmin, but I encountered this error:Failed loading /usr/local/lib/ioncube_loader_lin_5.2.so: /usr/local/lib/ioncube_loader_lin_5.2.so: undefined symbol: php_body_write
|
How to resolve this error in DirectAdmin
|
To run every minute, the cron job schedule should be* * * * *.1 0 * * *means to execute every day at00:01.
|
I am trying to run a cron job every minute that will insert a new row into a specific table every minute.
I added the path to thefeedUpdate.phpfile and1 0 * * *to execute it every minute. ThefeedUpdate.phplooks like this:<?php
require_once("../php_includes/db_conx.php");
$sql = "SELECT * FROM posts ORDER BY RAND() LIMIT 1"; //Select a random row from 'posts'
$query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
$id = $row['id']; //get the id of that specific random post selected
$sqlins = "INSERT INTO postfeed (postid, time) VALUES ('$id',now())"; //Insert the new post id into the feed table.
$queryins = mysqli_query($db_conx, $sqlins);
?>This script works fine when I just write the path directly in the browser, but it doesn't run automatically every minute.Any ideas why?I am using 000webhost at the moment as it's free, but I know for a fact that it does run cron jobs as I have one that runs daily clearing temporary files.
|
Insert new row into table every minute with cron job
|
Whenever is a sort of "wrapper" tool around system cron; there's no reason to write a custom batch to setup rails environment and launch tasks, as whenever does exactly this job.
It plays nicely with capistrano and mina, both having the ability to update the crontab during deployment.Take a look at thewhenever documentationand atmina documentationto have a clearer idea.Cheers!
|
I'm wondering how does one implement a cron job like feature in rails.For instance, you have a member model. My system sends a SMS welcome message each time a new member sign up. However, if this user has been greeted before, don't send it again. Thus, each 10 minutes I'd like to look into the member table, and see who shall I send the message to.This is simply an example, and I'm aware it's easier to implement otherwise. However I'd like to know if for a cron job like task, which has to look into the active records1) where shall I put the script?
2) is it a good practice to access the db via active records directly?
3) shall I use a gem like whenever? or in this situation would be easier to implement just using system cron?Thanks!
|
How shall I implement a "cron" like feature in rails?
|
The highest resolution for cron is minutes, so you can make the script run every minute like this :* * * * * * /path/to/script.sh
|
Trying to execute shell script from crontab, every 10 seconds but it is not working for me* * * * * sleep 10 /path/dataimport.shscript just has one commandrake db:dataimport
|
execute shell script from crontab
|
You can't do it in cron directly. Cron doesn't support fractions in the time. You've got 2 options really:Write your own wrapper which will run the task when needed.Use an ugly hack in cron to schedule two tasks at the same time:in your crontab:*/25 * * * * the_task
*/25 * * * * sleep 750 ; the_taskThis will spawn both tasks at the same time, but run the second one after sleeping 12.5 minutes. Just make sure your cron does start both tasks at the same time - I don't think the behaviour on 'every x minutes' is standardised.
|
How to handle fractions with cron? I want to schedule a task to run every 7.5 minutes, was not able to succeed with that.Basically, 8 times in an hour.Thanks
|
Every 7.5 minutes with cron
|
Create a route with controller>function Select all reminder with expiry date and then check in your sql query if $result > 0then is_show to make 1Refresh ajax request to 15if any reminder then show the reminder
|
I have reminders in my database, all reminders are shown in a HTML table with the following fields:id, name, phone, email, messageShould I use a CRON job with 5 sec to check which reminder needs to be displayed or should I save date in the HTML page and then try to check date with the help of JavaScript? I have no experience creating reminders before.Database:+----+-----------------+---------------------+
| ID | expiry | created_at |
+----+-----------------+---------------------+
| 1 | 2015-07-9 14:36 | 2015-07-01 11:22:24 |
+----+-----------------+---------------------+
| 2 | 2015-07-9 14:38 | 2015-07-01 11:22:24 |
+----+-----------------+---------------------+
| 3 | 2015-07-9 14:40 | 2015-07-01 11:22:24 |
+----+-----------------+---------------------+
| 4 | 2015-07-9 14:50 | 2015-07-01 11:22:24 |
+----+-----------------+---------------------+
|
PHP show reminders from database
|
Cron itself does not provide persistent storage (not counting crontabs themselves), so you will have to store state manually - in a file, database or even shared memory segment.
|
I have a linux cron job that runs every 10 minutes. It basically runs a ruby script that fetches some data and does calculations. I want to pass data from one successful execution of the cron to the next. Right now I am thinking of simply storing the data in a file and reading it from there.Is there a better way of doing this?
|
Persist data between successive cron job calls
|
I've usedhttps://github.com/percolatestudio/meteor-synced-cronin an app to check if invoices are due and then fire up email reminders. The jobs run on startup but if you set it to go through the collection of jobs, check the time they were created, and then fire something 2 hours after the creation, I'm sure you'll be able to get the work you need done
|
I'm currently in the process of building an app in MeteorJS that allows users to create jobs and schedule them, e.g. Posting a link to social media every 2 hours. Are there any Meteor or Node packages that would make this possible? I've looked intohttps://github.com/percolatestudio/meteor-synced-cron, but I'm not sure that this would be the right approach for user submitted jobs (seems to be for jobs you create on app start-up). The idea would be that users could create these jobs and delete them later.Thanks!
|
User Created Job Scheduling
|
Pipes are a new feature inPandas 0.16.2.Example:import pandas as pd
from sklearn.datasets import load_iris
x = load_iris()
x = pd.DataFrame(x.data, columns=x.feature_names)
def remove_units(df):
df.columns = pd.Index(map(lambda x: x.replace(" (cm)", ""), df.columns))
return df
def length_times_width(df):
df['sepal length*width'] = df['sepal length'] * df['sepal width']
df['petal length*width'] = df['petal length'] * df['petal width']
x.pipe(remove_units).pipe(length_times_width)
xNB: The Pandas version retains Python's reference semantics. That's whylength_times_widthdoesn't need a return value; it modifiesxin place.
|
In R (thanks tomagrittr) you can now perform operations with a more functional piping syntax via%>%. This means that instead of coding this:> as.Date("2014-01-01")
> as.character((sqrt(12)^2)You could also do this:> "2014-01-01" %>% as.Date
> 12 %>% sqrt %>% .^2 %>% as.characterTo me this is more readable and this extends to use cases beyond the dataframe. Does the python language have support for something similar?
|
Functional pipes in python like %>% from R's magrittr
|
The only difference is thatmake_pipelinegenerates names for steps automatically.Step names are needed e.g. if you want to use a pipeline with model selection utilities (e.g. GridSearchCV). With grid search you need to specify parameters for various steps of a pipeline:pipe = Pipeline([('vec', CountVectorizer()), ('clf', LogisticRegression()])
param_grid = [{'clf__C': [1, 10, 100, 1000]}
gs = GridSearchCV(pipe, param_grid)
gs.fit(X, y)compare it with make_pipeline:pipe = make_pipeline(CountVectorizer(), LogisticRegression())
param_grid = [{'logisticregression__C': [1, 10, 100, 1000]}
gs = GridSearchCV(pipe, param_grid)
gs.fit(X, y)So, withPipeline:names are explicit, you don't have to figure them out if you need them;name doesn't change if you change estimator/transformer used in a step, e.g. if you replace LogisticRegression() with LinearSVC() you can still useclf__C.make_pipeline:shorter and arguably more readable notation;names are auto-generated using a straightforward rule (lowercase name of an estimator).When to use them is up to you :) I prefer make_pipeline for quick experiments and Pipeline for more stable code; a rule of thumb: IPython Notebook -> make_pipeline; Python module in a larger project -> Pipeline. But it is certainly not a big deal to use make_pipeline in a module or Pipeline in a short script or a notebook.
|
I got this from thesklearnwebpage:Pipeline: Pipeline of transforms with a final estimatorMake_pipeline: Construct a Pipeline from the given estimators. This is a shorthand for the Pipeline constructor.But I still do not understand when I have to use each one. Can anyone give me an example?
|
What is the difference between pipeline and make_pipeline in scikit-learn?
|
Use-as the input file:cat largefile.tgz.aa largefile.tgz.ab | tar zxf -Make sure you cat them in the same order they were split.If you're using zsh you can use the multios feature and avoid invoking cat:< largefile.tgz.aa < largefile.tgz.ab tar zxf -Or if they are in alphabetical order:<largefile.tgz.* | tar zxf -
|
I have a large tar file Isplit. Is it possible tocatand untar the file using pipeline.Something like:cat largefile.tgz.aa largefile.tgz.ab | tar -xzinstead of:cat largefile.tgz.aa largfile.tgz.ab > largefile.tgz
tar -xzf largefile.tgzI have been looking around and I can't find the answer. I wanted to see if it was possible.
|
How to extract tar archive from stdin?
|
Did you look at the documentation:http://scikit-learn.org/dev/modules/pipeline.htmlI feel it is pretty clear.Update: in 0.21 you can use just square brackets:pipeline['pca']or indicespipeline[1]There are two ways to get to the steps in a pipeline, either using indices or using the string names you gave:pipeline.named_steps['pca']
pipeline.steps[1][1]This will give you the PCA object, on which you can get components.
Withnamed_stepsyou can also use attribute access with a.which allows autocompletion:pipeline.names_steps.pca.<tab here gives autocomplete>
|
I typically getPCAloadings like this:pca = PCA(n_components=2)
X_t = pca.fit(X).transform(X)
loadings = pca.components_If I runPCAusing a scikit-learn pipeline:from sklearn.pipeline import Pipeline
pipeline = Pipeline(steps=[
('scaling',StandardScaler()),
('pca',PCA(n_components=2))
])
X_t=pipeline.fit_transform(X)is it possible to get the loadings?Simply tryingloadings = pipeline.components_fails:AttributeError: 'Pipeline' object has no attribute 'components_'(Also interested in extracting attributes likecoef_from pipelines.)
|
Getting model attributes from pipeline
|
Although it has been passed much time on this discussion I would like to suggest an opinion, which I am using most of the time.rules:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"'
when: on_success
changes:
- folder/some_folder/**/*
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_BRANCH == "development"'
when: manual
changes:
- folder/some_other_folder/**/*This structure solved my various problems, I hope it helps you to!Regards.
|
I'm trying to implement GitLab CI Pipelines to build and deploy an Angular app. In our project we have two general branches:master(for production only) anddevelop. For development we createfeature/some-featurebranches fromdevelopbranch. When development finished, we create merge request fromfeature/some-featuretodevelop. When merge request approved and merged intodevelopbranch I want to run a Pipeline in order to build application and deploy the build on some environment.I use the following setup in .gitlab-ci.yml:image: node:7.5-configured
stages:
- build
- deploy
build_job:
stage: build
only:
- develop
script:
- /bin/bash <some script here>
...The problem is that Pipeline executed every time I push into anyfeature/some-featurebranch. What's wrong with my setup? How can I force the Pipeline to be executedonlywhen push performed intodevelopbranch directly?SolutionIt was my mistake - I had two different .gitlab-ci.yml files indevelopbranch andfeature/some-featurebranch.
|
GitLab CI Pipeline on specific branch only
|
import joblib
joblib.dump(grid.best_estimator_, 'filename.pkl')If you want to dump your object into one file - use:joblib.dump(grid.best_estimator_, 'filename.pkl', compress = 1)
|
After identifying the best parameters using apipelineandGridSearchCV, how do Ipickle/joblibthis process to re-use later? I see how to do this when it's a single classifier...import joblib
joblib.dump(clf, 'filename.pkl')But how do I save this overallpipelinewith the best parameters after performing and completing agridsearch?I tried:joblib.dump(grid, 'output.pkl')- But that dumped every gridsearch attempt (many files)joblib.dump(pipeline, 'output.pkl')- But I don't think that contains the best parametersX_train = df['Keyword']
y_train = df['Ad Group']
pipeline = Pipeline([
('tfidf', TfidfVectorizer()),
('sgd', SGDClassifier())
])
parameters = {'tfidf__ngram_range': [(1, 1), (1, 2)],
'tfidf__use_idf': (True, False),
'tfidf__max_df': [0.25, 0.5, 0.75, 1.0],
'tfidf__max_features': [10, 50, 100, 250, 500, 1000, None],
'tfidf__stop_words': ('english', None),
'tfidf__smooth_idf': (True, False),
'tfidf__norm': ('l1', 'l2', None),
}
grid = GridSearchCV(pipeline, parameters, cv=2, verbose=1)
grid.fit(X_train, y_train)
#These were the best combination of tuning parameters discovered
##best_params = {'tfidf__max_features': None, 'tfidf__use_idf': False,
## 'tfidf__smooth_idf': False, 'tfidf__ngram_range': (1, 2),
## 'tfidf__max_df': 1.0, 'tfidf__stop_words': 'english',
## 'tfidf__norm': 'l2'}
|
Sklearn How to Save a Model Created From a Pipeline and GridSearchCV Using Joblib or Pickle?
|
You need towrap your Keras model as a Scikit learn modelfirst and then proceed as usual.Here's a quick example (I've omitted the imports for brevity)Here is a full blog post with this one and many other examples:Scikit-learn Pipeline Examples# create a function that returns a model, taking as parameters things you
# want to verify using cross-valdiation and model selection
def create_model(optimizer='adagrad',
kernel_initializer='glorot_uniform',
dropout=0.2):
model = Sequential()
model.add(Dense(64,activation='relu',kernel_initializer=kernel_initializer))
model.add(Dropout(dropout))
model.add(Dense(1,activation='sigmoid',kernel_initializer=kernel_initializer))
model.compile(loss='binary_crossentropy',optimizer=optimizer, metrics=['accuracy'])
return model
# wrap the model using the function you created
clf = KerasRegressor(build_fn=create_model,verbose=0)
# just create the pipeline
pipeline = Pipeline([
('clf',clf)
])
pipeline.fit(X_train, y_train)
|
I'm using ascikit-learncustom pipeline (sklearn.pipeline.Pipeline) in conjunction withRandomizedSearchCVfor hyper-parameter optimization. This works great.Now I would like to insert akerasmodel as a first step into the pipeline. The parameters of the model should be optimized. The computed (fitted)kerasmodel should then be used later on in the pipeline by other steps, so I think I have to store the model as a global variable so that the other pipeline steps can use it. Is this right?I know thatkerasoffers somewrappersfor thescikit-learnAPI, but the problem is that thesewrappersalready do classification/regression, but I only want to compute thekerasmodel and nothing else.How can this be done?For example, I have a method which returns the model:def create_model(file_path, argument2,...):
...
return modelThe method needs some fixed parameters like afile_pathetc. butXandyare not needed (or can be ignored). The parameters of the model should be optimized (number of layers etc.).
|
How to insert Keras model into scikit-learn pipeline?
|
Check the latest correct doc here:https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_reportSome of the docs are in somewhat of a messy state right now, due to the new release as mentioned.This was the fix for me:artifacts:
expire_in: 2 days
reports:
coverage_report:
coverage_format: cobertura
path: python_app/coverage.xml
|
I'm not able run the gitlab pipeline due to this errorInvalid CI config YAML file
jobs:run tests:artifacts:reports config contains unknown keys: cobertura
|
Gitlab pipeline - reports config contains unknown keys: cobertura
|
Dual issue means that each clock cycle the processor can move two instructions from one stage of the pipeline to the next stage. Where this happens depends on the processor and the company's terminology: it can mean that two instructions are moved from a decode queue to a reordering queue (Intel calls this issue) or it could mean moving instructions (or micro-operations or something) from a reordering queue to an execution port (afaik IBM calls this issue, while Intel calls it dispatch)But really broadly speaking it should usually mean you can sustain executing two instructions per cycle.Since you tagged this ARM, I think they're using Intel's terminology. Cortex-A8 and Cortex-A9 can, each cycle, fetch two instructions (more in Thumb-2), decode two instructions, and "issue" two instructions. On Cortex-A8 there's no out of order execution, although I can't remember if there's still a decode queue that you issue to - if not you'd go straight from decoding instructions to inserting them into two execution pipelines. On Cortex-A9 there's an issue queue, so the decoded instructions are issued there - then the instructions are dispatched at up to 4 per cycle to the execution pipelines.
|
I came across several references to the concept of adual issueprocessor (I hope this even makes sense in a sentence). I can't find any explanation of what exactly dual issue is. Google gives me links to micro-controller specification, but the concept isn't explained anywhere. Here's an example of suchreference. Am I looking in the wrong place? A brief paragraph on what it is would be very helpful.
|
What exactly is a dual-issue processor?
|
UPDATE(2021-05-04)Please note that this answer is now ~7 years old, so it's validity can no longer be ensured. In addition it is using Python2The way to access your Scrapy settings (as defined insettings.py) from withinyour_spider.pyis simple. All other answers are way too complicated. The reason for this is the very poor maintenance of the Scrapy documentation, combined with many recent updates & changes. Neither in the "Settings" documentation "How to access settings", nor in the"Settings API"have they bothered giving any workable example. Here's an example, how to get your currentUSER_AGENTstring.Just add the following lines toyour_spider.py:# To get your settings from (settings.py):
from scrapy.utils.project import get_project_settings
...
class YourSpider(BaseSpider):
...
def parse(self, response):
...
settings = get_project_settings()
print "Your USER_AGENT is:\n%s" % (settings.get('USER_AGENT'))
...As you can see, there's no need to use@classmethodor re-define thefrom_crawler()or__init__()functions. Hope this helps.PS.I'm still not sure why usingfrom scrapy.settings import Settingsdoesn't work the same way, since it would be the more obvious choice of import?
|
How do I access the scrapy settings in settings.py from the item pipeline. The documentation mentions it can be accessed through the crawler in extensions, but I don't see how to access the crawler in the pipelines.
|
How to access scrapy settings from item Pipeline
|
Check RenderCapability.TierGraphics Rendering TiersRenderCapability Class[UPDATE]RenderCapability.IsPixelShaderVersionSupported- Gets a value that indicates whether the specified pixel shader version is supported.RenderCapability.IsShaderEffectSoftwareRenderingSupported- Gets a value that indicates whether the system can render bitmap effects in software.RenderCapability.Tier- Gets a value that indicates the rendering tier for the current thread.RenderCapability.TierChanged- Occurs when the rendering tier has changed for the Dispatcher object of the current thread.RenderCapability.Tier >> 16Rendering Tier 0- No graphics hardware acceleration. The DirectX version level is less than version 7.0.Rendering Tier 1- Partial graphics hardware acceleration. The DirectX version level is greater than or equal to version 7.0, and lesser than version 9.0.Rendering Tier 2- Most graphics features use graphics hardware acceleration. The DirectX version level is greater than or equal to version 9.0.
|
I'm benchmarking a WPF application on various platforms and I need an easy way to determine if WPF is using hardware or software rendering.I seem to recall a call to determine this, but can't lay my hands on it right now.Also, is there an easy, code based way to force one rendering pipeline over the other?
|
How do you determine if WPF is using Hardware or Software Rendering?
|
For all those still wondering, I contacted Gitlab recently & apparently it's an open issue with them. They said it's possible to merge the branches anyway, but in the end we just added the credit card details anyway (there was a temporary charge). Not ideal, but hopefully will get sorted soon.
|
When a non-owner dev pushes a branch to our Gitlab repo, it returns a "pipeline failed" message, with the detail "Pipeline failed due to the user not being verified". On the dev's account, he's getting a prompt to add a credit card to verify him to be eligible for free pipeline minutes.But I haven't set up any pipelines - I don't have a gitlab-ci.yml file in my repo, neither does the new branch. There are no jobs or schedules under the CI/CD tab of the project on Gitlab. So why is there a marker saying the branch failed in the pipeline?
|
Why am I getting "Pipeline failed due to the user not being verified" & "Detached merge request pipeline" on a Gitlab merge request?
|
Calling a function pointer is not fundamentally different from calling a virtual method in C++, nor, for that matter, is it fundamentally different from a return. The processor, in looking ahead, will recognize that a branch via pointer is coming up and will decide if it can, in the prefetch pipeline, safely and effectively resolve the pointer and follow that path. This is obviously more difficult and expensive than following a regular relative branch, but, since indirect branches are so common in modern programs, it's something that most processors will attempt.As Oli said, "clearing" the pipeline would only be necessary if there was a mis-prediction on a conditional branch, which has nothing to do with whether the branch is by offset or by variable address. However, processors may have policies that predict differently depending on the type of branch address -- in general a processor would be less likely to agressively follow an indirect path off of a conditional branch because of the possibility of a bad address.
|
Modern CPUs have extensive pipelining, that is, they are loading necessary instructions and data long before they actually execute the instruction.Sometimes, the data loaded into the pipeline gets invalidated, and the pipeline must be cleared and reloaded with new data. The time it takes to refill the pipeline can be considerable, and cause a performance slowdown.If I call a function pointer in C, is the pipeline smart enough to realize that the pointer in the pipeline is a function pointer, and that it should follow that pointer for the next instructions? Or will having a function pointer cause the pipeline to clear and reduce performance?I'm working in C, but I imagine this is even more important in C++ where many function calls are through v-tables.edit@JensGustedt writes:To be a real performance hit for function calls, the function that you
call must be extremely brief. If you observe this by measuring your
code, you definitively should revisit your design to allow that call
to be inlinedUnfortunately, that may be the trap that I fell into.I wrote the target function small and fast for performance reasons.But it is referenced by a function-pointer so that it can easily be replaced with other functions (Just make the pointer reference a different function!). Because I refer to it via a function-pointer, I don't think it can be inlined.So, I have an extremely brief, not-inlined function.
|
Do function pointers force an instruction pipeline to clear?
|
ls | %{C:\Working\tools\custom-tool.exe $_}As each object comes down the pipeline the tool will be run against it. Putting quotes around the command string causes it to be... a string! The local variable "$_" it then likely doesn't know what to do with so pukes with an error.
|
I'm trying to get this simple PowerShell script working, but I think something is fundamentally wrong. ;-)ls | ForEach { "C:\Working\tools\custom-tool.exe" $_ }I basically want to get files in a directory, and pass them one by one as arguments to the custom tool.
|
Run a program in a ForEach loop
|
UseKernel.elem/2:iex(1)> {[:ok, :ok, :ok], [1, 1, 3]} |> elem(1)
[1, 1, 3]
|
I want to be able to extract the Nth item of a tuple in a pipeline, without usingwithor otherwise breaking up the pipeline.Enum.atwould work perfectly except for the fact that a tuple is not an enum.Here's a motivating example:colors = %{red: 1, green: 2, blue: 3}
data = [:red, :red, :blue]
data
|> Enum.map(&Map.fetch(colors, &1))
|> Enum.unzipThis returns{[:ok, :ok, :ok], [1, 1, 3]}and let's say I just want to extract[1, 1, 3](For this specific case I could usefetch!but for my actual code that doesn't exist.)I could add on|> Tuple.to_list
|> Enum.at(1)Is there a better way of doing this that doesn't require creating a temporary list out of each tuple?
|
Extract the second element of a tuple in a pipeline
|
This doesnotcreate an object in the global environment:df %>%
filter(b < 3) %>%
{
{ . -> tmp } %>%
mutate(b = b*2) %>%
bind_rows(tmp)
}This can also be used for debugging if you use. ->> tmpinstead of. -> tmpor insert this into the pipeline:{ browser(); . } %>%
|
Q: In an R dplyr pipeline, how can I assign some intermediate output to a temp variable for use further down the pipeline?My approach below works. But it assigns into the global frame, which is undesirable. There has to be a better way, right? I figured my approach involving the commented line would get the desired results. No dice. Confused why that didn't work.df <- data.frame(a = LETTERS[1:3], b=1:3)
df %>%
filter(b < 3) %>%
assign("tmp", ., envir = .GlobalEnv) %>% # works
#assign("tmp", .) %>% # doesn't work
mutate(b = b*2) %>%
bind_rows(tmp)
a b
1 A 2
2 B 4
3 A 1
4 B 2
|
Assign intermediate output to temp variable as part of dplyr pipeline
|
Use command substitution instead, so your example would look like:sed -i "s/$(echo "some pattern")/replacement/g" file.txtThe double quotes allow for the command substitution to work while preventing spaces from being split.
|
I need to use the output of a command as a search pattern in sed. I will make an example using echo, but assume that can be a more complicated command:echo "some pattern" | xargs sed -i 's/{}/replacement/g' file.txtThat command doesn't work because "some pattern" has a whitespace, but I think that clearly illustrate my problem.How can I make that command work?Thanks in advance,
|
how to use xargs with sed in search pattern
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.