w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How to run a Python script online every N minutes?
If you have shell access, you an use crontab to schedule a recurring job. Otherwise you can use a service like SetCronJob or EasyCron or similar to invoke a script regularly. Some hosters also provide similar functionalities in their administration interface...

Categories : Python

How to write Gradle startup script
I wrote the following init script for starting gradle applications at system startup for redhat distros (centos/fedora etc). You need to perform a few steps to tie it all together: deploy your gradle application using gradle distZip onto your target server create a configuration file /etc/my-service.conf link the init script (see below) to the service name in /etc/init.d/my-service An example configuration file /etc/my-service.conf username=someunixuser serviceName=MyStandaloneServer prog="/path/to/bin/MyStandaloneServer -a any -p params -y you -w want" javaClass="some.java.MyStandaloneServer" Note the path to the application from the distZip in the prog line. You then link the init script to the actual service you want it to be run as, e.g. ln -s /path/to/gradle-init-start-stop

Categories : Gradle

Mac OSX LaunchDaemon on Startup, Shell Script with SSH
What errors are you seeing? I would expect that you may have a PATH problem here. Where is mysqldump? If it's in /usr/local/bin, then you probably want to make that explicit, or set the default path in /etc/launchd.conf.

Categories : Osx

How to execute SQL script only once at startup in Spring?
Have your CustomerJDBCTemplate implement InitializingBean. afterPropertiesSet will get called once, right after all properties have been set by Spring's BeanFactory. For example: public class CustomerJDBCTemplate implements CustomerDAO, InitializingBean { ... // ......other methods public void afterPropertiesSet() throws Exception { //do your initializing, or call your initializing methods } }

Categories : Spring

Linux startup script instead init.d
The file /etc/rc.local is a good candidate for local jobs, and it avoids some of the complexity of using /etc/init.d/ and similar directories. Just add a line to /etc/rc.local to launch your job.

Categories : Linux

Source other scripts in Linux startup script
From execve(2) on a fairly current Linux system: Interpreter scripts An interpreter script is a text file that has execute permission enabled and whose first line is of the form: #! interpreter [optional-arg] The interpreter must be a valid pathname for an executable which is not itself a script. If the filename argument of execve() specifies an interpreter script, then interpreter will be invoked with the following arguments: interpreter [optional-arg] filename arg... where arg... is the series of words pointed to by the argv argument of execve(). For portable use, optional-arg should either be absent, or be specified as a single word (i.e., it should not contain white space); [...] I have not seen many scripts in the wild using the #!/bin/sh fi

Categories : Linux

Need a startup script in windows to send ALT+F11 keys
Hopefully a login vbscript will work for you. Either append this to an existing login script or save it as a ".vbs" file. Microsoft has some good tutorials if you are unfamiliar with login scripts. Set WshShell = CreateObject("Wscript.Shell") 'Create wshell object WScript.Sleep(5000) 'Lets wait 5 seconds WshShell.AppActivate "EXACT TITLE OF THE WINDOW YOU WANT" 'EDIT THIS LINE! 'The line above selects the window so we make sure the keystrokes are sent to it WshShell.SendKeys "%{F11}" 'Send ALT+F11 Wscript.Quit 'Quit the script

Categories : Batch File

starting a python 3.3. script at ubuntu startup
The shebang line #!/usr/bin/python3 should work if sh, bash, etc. is trying to launch your script. It it is being run from another script as python myscript.py you'll have to find that script and get it to launch the script using python3 myscripy.py

Categories : Python

Execute a script on startup of SUSE reboot
chmod +x /etc/init.d/testing touch /etc/init.d/rc.d/rc3.d/S12testing Should not be 'touch', but a symbolic link (ln -s) to /etc/init.d/testing. Try cd /etc/init.d/rc.d/rc3.d ln -s ../../testing S12testing Hope this helps.

Categories : Linux

Automatically load map in R from script on startup error
The problem you are getting is that .First scripts can only use functions in the base package, unless the packages have been explicitly loaded. So in your case, you need to load utils for the data function. graphics for the par function. Putting this together gives: .First <- function() { library(utils); library(graphics) library(maps) library(maptools) library(mapdata) map('worldHires', c('UK', 'Ireland', 'Isle of Man','Isle of Wight'), xlim=c(-11,3), ylim=c(49,60.9)) }

Categories : R

ubuntu ec2 - run python script at startup with arguments
Your /etc/init.d/script_name is missing the plumbing that update-rc.d and so on use, and won't properly handle stop, start, and other init-variety commands, so... For initial experimentation, take advantage of the /etc/init.d/rc.local script (which should be linked to by default from /etc/rc2/S99rc.local). The gets you out of having to worry about the init.d conventions and just add things to /etc/rc.local before the exit 0 at its end. Additionally, that ~ isn't going to be defined, you'll need to use a full pathname - and furthermore the script will run as root. We'll address how to avoid this if desired in a bit. In any of these, you'll need to replace "whoeveryouare" with something more useful. Also be warned that you may need to prefix the python command with a su command and som

Categories : Python

Startup script to generate uninstall command
@ECHO OFF SETLOCAL FOR /f "tokens=1*" %%i IN (yourtextfilename.txt) DO ( IF /i %%i==%COMPUTERNAME% ECHO MSIEXEC /x install.msi key=%%j ) This should do as you require - yourtextfilename.txt contains the data, presumably on a shared drive; finds the line where the computername in column 1 is the same as the computername returned by %computername% in the target computer's environment. (all case-insensitive EXCEPT %%i and %%j which must match and be the same case) Command simply ECHOed - remove the ECHO keyword after verification to activate.

Categories : Windows

Run a bash script on startup, before login as a user
Try su minecraft -c '/bin/bash /path/to/script/script.sh &' The user should be the first argument to su. You should use quotes and not ticks for the command argument (-c) You may want to consider using su -l minecraft to have the script run in an environment which would be similar to that if the user minecraft logged in directly. Give this a shot and let me know if it works.

Categories : Bash

Issue on reading a CSV file into FME through a startup python script
Did you have a look at the file that your python script writes to your disk? This might at least show you why there is a difference. I don't think this has anything to do with FME. In FME2013 you can directly use the reader to access a web-based source dataset. This works for any file-based format and even zipped data. So you don't need to use the python-script to download the file before.

Categories : Csv

How do I fix "Error: MONGO_URL must be set in environment" on ubuntu using forever and startup script?
Try passing it onto forever straight without using the export before: exec PORT=80 MONGO_URL=mongodb://localhost27017/parties ROOT_URL=http://ec2-54-235-1-185.compute-1.amazonaws.com forever start bundle/main.js It might have something to do with the permissions, when using a startup script the user might be something that has its own variable scope to the ones set.

Categories : Ubuntu

Spring/REST Application with HOT Deployment: Groovy script does not load dynamically from applicationContext.xml on tomcat startup at runtime
Try creating the controller with Java/Groovy that is compiled and let it get injected the Groovy 'script' as a dependency to do the actual work. I seem to remember doing this before and it might be the annotations or the way Spring loads controllers that makes the 'script' not work for you properly.

Categories : Rest

converting secondcolumn value(minutes) to hour:minutes:second using sql
Not the easiest thing to do, but it's not rocket science. What I did was get the averge seconds in the sub query, then div the seconds by 3600, which gets you hours 1). To get the minutes 2), I subtract from the average seconds all the seconds accounted for in the hours. Then 3), to get the leftover seconds, I added together all the seconds accounted for in the hours, all the seconds accounted for in the minutes and then subtracted those seconds from the average seconds, which gives you the leftover seconds. The casting is necessary when you concat the numbers to text select cast(AvgSec/3600 as varchar(2)) +':' --1) gets hours +cast(AvgSec/60 -((AvgSec/3600) * 60) as varchar(2)) +':' --2) gets minutes +cast((AvgSec - ((((AvgSec/3600) *60)*60)

Categories : SQL

How can i logout a jsp page after 3 minutes if its inactive for 3 minutes?
var timer = null; function auto_reload() { window.location = 'http://domain.com/page.php'; } and in tab body of html, you write : <body onload="timer = setTimeout('auto_reload()',180000);"> Edit : THIS IS ONLY RUN IN SINGLE TAB.

Categories : Javascript

converting minutes to hour:minutes:second in sql
marc_s is right with his comment. What you need is a function like in this answer. You would then call it like this: SELECT udfTimeSpanFromSeconds(SUM(DATEDIFF(SECOND, t.Paydate, t.DelDate))) AS 'HH:MM:SS' FROM Transaction_tbl t WHERE t.transactID in (24, 25) group by vtid

Categories : Sql Server

node - mysql query that takes a few minutes repeating itself after a few minutes before finishing the original query
Consider async api: on the server handler immediately respond with HTTP 200 and some id, and there is another endpoint to check if insert command with id finished. Be aware that your code prone to sql injection attack. Better approach: var params = req.body; // you may want to filter names explicitly here connection.query('CALL filldates(?,?,?,?,...)', params, function(err, result, fields){ if (err){ console.log("error is" + err); return res.send(500, "fail"); } else{ console.log("finsihed"); return res.send(200); } }); This would escape all dangerous chars on client before sending query, or use prepared statements with mysql2 to send query intdependent of parameters: var params = req.body; // you may want to filter names explicitl

Categories : Javascript

Counting number of transactions within past 5 minutes on a particular day, at a particular store, at a particular terminal within the past 5 minutes
TL; DR Use a SQL subquery. They are fast (especially if you can pass execution off to the DBMS) and easy to maintain. PROC SQL NOPRINT; CREATE TABLE Work.TransWithCount AS SELECT STORE_NUM , TERMINAL , TRANS_DT , ( SELECT COUNT(*) FROM Work.Trans AS T WHERE T.STORE_NUM = P.STORE_NUM AND T.TERMINAL = P.TERMINAL AND T.TRANS_DT >= P.START_DT AND T.TRANS_DT <= P.END_DT ) AS TRANS_COUNT FROM Work.Trans AS P ; QUIT; A non-SQL approach is also possible, but it's much more complicated. See the update below. Main I can't promise that thi

Categories : SQL

Jetty Startup issue: WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,null}
It seems that your eclipse STS workspace is out of sync with the content published in the server. Try to clean the server, clean the working directory, clean all projects and Republish the project into the server. If this does not work, try these steps to regenerate your eclipse workspace: close eclipse and do a maven clean install from the command line delete all eclipse related files: .project, .classpath and .settings reopen eclipse, and configure maven to use the same maven as the command line import the project using 'Import as Maven Project' scrap your Jetty and redownload a clean one Create a new Jetty server, point it to the new Jetty and add your application to it Republish the application and start the server

Categories : Eclipse

Bash script to wait for gnome-terminal to finish before continuing script, only works for first instance of script
#!/bin/bash date bash -c "sleep 7" & bash -c "sleep 5" & wait date As you can see while running this script, both sleep commands will run in parallel, but main thread stalls, while they are running. Sat. Jule 27 01:11:49 2013 Sat. Jule 27 01:11:56 2013 Replace sleep 7 with expect launchneuron.exp and sleep 5 with expect launchmpj.exp and add your plot commands after calling "wait": echo "Simulation Complete" ...(your code to plot results)

Categories : Bash

PowerShell - script 1 calls script 2 - how to return value from script 2 to script 1
You could make use of ProcessStartInfo and Process which would allow you to read the StandardOutput. Here's an example of what you might do: $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = "powershell.exe" $startInfo.Arguments = "C:scriptscript2.ps1" $startInfo.RedirectStandardOutput = $true $startInfo.UseShellExecute = $false $startInfo.CreateNoWindow = $false $startInfo.Username = "DOMAINUsername" $startInfo.Password = $password $process = New-Object System.Diagnostics.Process $process.StartInfo = $startInfo $process.Start() | Out-Null $standardOut = $process.StandardOutput.ReadToEnd() $process.WaitForExit() # $standardOut should contain the results of "C:scriptscript2.ps1" $standardOut

Categories : Powershell

How do I get the minutes?
Here is what you are trying to do (sorry, I changed variables names, yours were not obvious): $time = array(1,5); $time_plus = '10s'; $time_plus = preg_replace('#D#', '', $time_plus); $minutes = $time [0] + (($time_plus + $time[1] >= 60) ? 1 : 0); $seconds = ($time[1] + $time_plus) % 60; echo $new_time = $minutes . ":" . $seconds; Demo: http://codepad.org/eOBNeHrq

Categories : PHP

Powershell start-process script calls a second script - how to make one script only
Windows does not allow a process to elevate while running. There are some tricks but in one way or another they will spawn a new process with the elevated rights. See here for more info. So the easiest way for PowerShell is still using one script to Start-Process the other script elevated.

Categories : Powershell

unable to access variable declared in ksh script to csh script using shell script
The ksh script is not doing what you think it is doing when used by ksh; it sets $1 first to MyUser=root and then MyPassword=shroot. However, when you source it from your C shell script, because the syntax is compatible with C shell (checked with tcsh), you would set the two variables. If you sourced the script from a Bourne-shell derivative, the exit at the end of the ksh script would cause the shell to exit; it does not seem to cause the C shell to exit. So, what you've got is a weird hybrid. Normally, you stick to one language and use it exclusively. Where you need to use another shell, you can do so, but you simply run the script written for the other shell. You can communicate to the other script with environment variables. You don't normally try writing sourceable code that ca

Categories : Shell

Google Apps Script Spreadsheets - Assign script to image from a script
This would be a cool feature, but here is a possible workaround, it might even offer more functionality. You can build a UI using Google API. More detailes here. The UI allows you to create side bars/menus/etc. You could even create floating dialog windows. Using AbsolutePanel, you can even choose where the dialogue shows up.

Categories : Google Apps Script

getting the time of X minutes ago in C
Since time(NULL) returns the time in seconds from the epoch (usually the Unix epoch) i.e. 00:00:00 UTC on 1 January 1970 (or 1970-01-01T00:00:00Z ISO 8601): #include <time.h> #include <stdio.h> time_t current_time; time_t tenMinutesAgo; int main() { char* c_time_string; current_time = time(NULL); tenMinutesAgo = current_time - 10*60;//the time 10 minutes ago is 10*60 c_time_string = ctime(&tenMinutesAgo);//convert the time tenMinutesAgo into a string format in the local time format printf("The time 10 minutes ago in seconds from the epoch is: %i ", (int)tenMinutesAgo); printf("The time 10 minutes ago from the epoch in the local time format is: %s ", c_time_string); return 0; } EDIT: @PaulGriffiths makes a good point in that my solution isn't guarantee

Categories : C

Post to an API every after 15 minutes
You can check this out , and use Intent Services to run in the back ground. android timer, For intent servicse check it out Intent Services

Categories : Android

Uptime help just 0 minutes
You're always returning the current time as the start time. Change TimeStarted so that you can set the value, and then set it when your program starts e.g. public static DateTime TimeStarted { get; set; } public static void Main(string[] args) { //set start time Program.TimeStarted = DateTime.UtcNow; } Instead of maintaining your own start time, you could use the one for the current process: DateTime processStartedAt = System.Diagnostics.Process.GetCurrentProcess().StartTime; to get the total number of seconds since the program started you can use the TotalSeconds property of TimeSpan. TimeSpan sinceStarted = (DateTime.UtcNow - Program.TimeStarted); double secondsRunning = sinceStarted.TotalSeconds; If you want to create a message to display, use the properties on the Ti

Categories : C#

PHP Auto Kill After X minutes
I suggest you two ways: 1- Using "set_time_limit" function that kills script after specified seconds and throws an error. 2- Define a variable before while loop and save time in that: $time=time(); At the end of the while loop add this code: if($time+TimeInSeconds<time()) exit(); These two ways can stop the script after some seconds. I hope it will help.

Categories : PHP

How to set remaining minutes counter in php
If your trying to play with timers and stuffs with php, I suggest you should play with it along with an AJAX script. If you ever tried using jquery ajax, everything would be much easier for you...

Categories : PHP

Xcode uses 16 gigs of RAM in 2 minutes
sounds like it is a problem with that version of Xcode. I am using 4.6.3, and have never experienced this, (although the apps I work on are never that big). You should definitely try Xcode 5, even if you cant submit to the appstore, at least you'll be able to work on your app. Then you MIGHT be able to open it in version 4.6.3, and submit it from there, not quite sure it will work, but its worth a shot. Make sure you keep a copy of what you have so far incase your Xcode 5 version wont work in 4.6.3, so you dont loose your work. hope this helps.

Categories : Xcode

Add minutes to current time
Your code is redundant. Why format a timestamp as a string, then convert that string back to a timestamp? Try $now = time(); $ten_minutes = $now + (10 * 60); $startDate = date('m-d-Y H:i:s', $now); $endDate = date('m-d-Y H:i:s', $ten_minutes); instead.

Categories : PHP

Value over threshold for n consecutive minutes
Basically, you want a cumulative sum of a flag saying that the column exceeds the value @x. It turns out that you can do this with some tricks using row_number(). Enumerate all the rows using row_number() (in time order). Then, enumerate all the rows, partitioning by the flag. The difference between these will be a constant that identifies a group of consecutive rows. Then, with aggregation, we can get the longest length of consecutive values where the flag is true (or false): select seqnum - seqnum_flag, count(*) from (select d.*, row_number() over (order by dt) as seqnum, row_number() over (partition by (case when val > @x then 1 else 0 end) order by dt) as seqnum_flag from tblData d ) d where val > @x group

Categories : SQL

FTP does not work after being 5 minutes inactive
If you really have to keep the connection alive, run NOOP commands against the server, so that the control connection remains alive. Either do it manually: client.sendNoOp(); Or set the client to do it at fixed interval rates: client.setControlKeepAliveTimeout(300); // set timeout to 5 minutes But if you can avoid wasting resources, logout and disconect after the initial download phase, do your local processing and connect / login again for uploading afterwards.

Categories : Java

SQL query is taking more than 10 minutes
Do you have indexes on (e.g.) TerritoryId? Also check: http://msdn.microsoft.com/en-us/library/ms345434.aspx and run SQL Server Profiler (under Tools-menu) And instead of the WHERE clause you can use the INNER JOIN clause

Categories : SQL

Timestamp: check if it has been 30 minutes
It is not safe to rely on strtotime() as it is defined by the system's timezone settings. You should adjust date.timezone setting or use the date_default_timezone_set() for example: date_default_timezone_set('America/New_York'); ... if($timenow - $chktime >= 1800) { echo "Yay! It has been 30 minutes!"; } else { echo "Wait! Its not been 30 minutes"; } EDIT: add the remaining time $time_diff = $timenow - $chktime; if( $time_diff >= 1800) { echo "Yay! It has been 30 minutes!"; } else { $remaining = (1800 - $time_diff ); echo "Wait! Its not been 30 minutes "; echo "please come back in ".date ( "i:s" , $remaining)." minutes"; }

Categories : PHP

filter post_where using minutes
strtotime() is a PHP function which you can read about here: http://php.net/manual/en/function.strtotime.php According to the manual, you could simply test with the string "now", or if you prefer, "+2 minutes". I could find no evidence that this function takes negative integers. I'm afraid I don't have time to test these suggestions, but it should be easy to try.

Categories : Wordpress

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.