How can I set up a 24 hours operation with iMacros? - javascript

How can I set up a 24 hours a day, 7 days a week (non-stop) operation with iMacros?
I Found that code but i can't adapt it my macro. i don't know use visual basic but i setup vbs 2008 today. How can i use that code on my imacros code? Anybody can tell it step by step on vbs. Thanks
'Sample code B
Set iim1= CreateObject ("imacros")
For m = 1 to 5000
iret = iim1.iimInit()
For n = 1 to 1000
iret = iim1.iimPlay ("macro1")
Next
iret = iim1.iimExit()
Next
Source: http://wiki.imacros.net/Web_Testing#Q:_How_can_I_set_up_a_24_hours_a_day.2C_7_days_a_week_.28non-stop.29_operation_with_iMacros.3F

I don't know about VB solution but JS solution is following.
Place SET !ERRORIGNORE YES command in macro and SET !TIMEOUT_MACRO 120 (you can change the time) inside the macro. Then when you call the macro in JS you do it like this.
iimPlay(macro, 110)
Make sure that the time is less then macro timeout by few seconds. That way macro will restart after each time and script can work a lot of time.

//this starts firefox
start /d"C:\Program Files\Mozilla Firefox" firefox.exe /AUTO
//this kills firefox process
pskill firefox.exe
//this command is one version of wait 10 seconds. You can change number 10 into some other for script to wait more then 10 seconds
ping -n 10 127.0.0.1
On this link you have examples on how to run iMacros file from bookmarks. So you have couple of examples and you can use them.
http://wiki.imacros.net/iMacros_for_Firefox#Command_Line_Support

Related

Discord.js Status Time Elapsed

I am using Discord.js Node V12
I am currently trying to find out how to say time elapsed in the status to show how long the bot has been online. But i cannot find anyone who has asked or answered any of these questions
Well, you can use client.uptime to get the amount of time your bot has been online (since it last booted up) in milliseconds. You can then take those milliseconds and convert them into whatever unit of time you choose. Here's an example, converted to hours:
var uptime = client.uptime; //in milliseconds
var hours = uptime / 1000 / 60 / 60 ; //milliseconds -> seconds -> minutes -> hours
If you're referring to how long the bot has been up since the first time you ever started it up, that's an entirely different answer, and you would need to clarify further on that. But if you just want total online time elapsed since the bot was last offline, this is the answer.
If you are using this in a command, you can retrieve client from the message object, like so:
var uptime = message.client.uptime; //in milliseconds
var hours = uptime / 1000 / 60 / 60 ; //milliseconds -> seconds -> minutes -> hours
I do not know why you could not find the answer, if my understanding of your question is correct, because this information can be found easily on this website and on discord.js docs.
Relevant resources:
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=uptime
https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=client

Can i use cron expression to start and end job

i tried this package cron.
const CronJob = require('cron').CronJob;
console.log('Before job instantiation');
const job = new CronJob('0 0 10-12,18-23 * * 0-6', function() {
upload //
});
console.log('After job instantiation');
job.start();
i need to upload all days in a week, in between 10-12 am and 6-11pm. so i need to start upload at 10 am and pause it in 12am. and again resume my upload at 6pm and pause at 11pm.
but this cron fires every one hour between 10-12 am and 6-10pm, but i need to sense only at 10 , 12 , 6 , 10 not in between hours.
how to do this ?
Your pattern for hours specifies two ranges "10-12,18-23", so it is doing what you told it to.
If you want to accomplish your goal, you should use "10,12,18,22' instead. Unless your goal really intended for 11 as the last hour then you should use 23 instead of 22.

node.js perf_hooks time output

I was reading up on the Performance Hooks now available in node and when I try to use one of their timing outputs like performanceEntry.duration, it says the output is in milliseconds. When I console.log out their code examples on that page like console.log(items.getEntries()[0].duration), the time output looks like this:
0.306935 (start mark)
3.656406 (end mark)
then when i use their startTime output items.getEntries()[0].startTime, I get time like this:
5346.841204
All time output on that documentation page says it is in milliseconds. However, I've never seen milliseconds with decimal places in it before. Are these actually seconds being output instead? If so, what would 5346.841204 correlate to exactly?

How to execute a function for each period of time?

I want a certain function to run every round hour. There is the solution of running an interval when it's a round hour but I often turn on and off my script and I don't want to have to run it exactly on a round hour.
I've tried looking through some npm modules and I found one but I had some issues with it. Does anyone have a solution?
No need for javascript! You have the perfect tool for that if you use linux!
Use cron:
$ sudo crontab -e
This will open a vim editor. Then add:
0 * * * * node /execute/your/script.js
(basically, it will run your code every hour on its minute zero)
More info
cron: https://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/
const HOUR = 1000 * 60 * 60;
function hourly() {
//....
setTimeout(hourly, HOUR);
}
setTimeout(hourly, HOUR - (new Date % HOUR));
Just calculate the next full hour when the server starts, and then shedule an hourly timer.
I admit that it might loose accuracy due to leap seconds :)

How to schedule execute a part of script in perl once every hour while the rest is refreshing every minute

I have a Perl script that refreshes the web page every minute. Now I want to add some MySQL queries that should once every hour. Is there a schedule executor in Perl like in JavaScript or can I incorporate JavaScript in Perl?
This solution is with Perl.
You can use localtime() function in perl.
Calculate the difference of an Hour and shoot MySQL queries.
To understand localtime() please visit this link.
OR
You can use CPAN's Time::HiRes.
Please read about Time::HiRes here.
OR
Follow this code:
use Time::Elapse;
## somewhere in your code...
Time::Elapse->lapse(my $now);
#...rest of code execution
print "Time Elapsed: $now\n";
I suggest something like this. Include a timestamp that is carried forward to next update (adjust the meta-tag so that occurs). Some issues if sql must be run at exactly 1 hrs, but I guess it it just some maintenance. The timestamp is only updated if the sql is run, and the sql is only run if the current time is more than one hour after the previous timestamp.
The following updates the timestamp with 3600 seconds instead of using the current time. Then we are very close to running it every hour.
Some web developers don't like using meta refresh in this way, so javascript or cookie may be an option. (but if this works for you, be happy :- )
use strict;
use CGI;
#time() is number of seconds since long time ago
my $lastrun = CGI->param('lastrun') || time();
#if hour is important (ie not 58 or 61 minutes) then need to
#consider the time spent running this script, etc
if (time() > $lastrun + 60 * 60) { #one hr is 60 sec * 60 min
$lastrun += 60 * 60; #udate timestamp before starting sql
#run sql
}
#do fixed stuff every minute
print qq|
Pragma: no-cache
Content-Type: text/html
<html><head>
<!-- remember to adust the url below ---vvvvvvvvvvvvvvvv-----here -- so time is ok vvvvv -->
<meta http-equiv="refresh" content="60;URL='http://example.com/script.pl?lastrun=$lastrun">
</head>
<body>hello again, waiting...</body>
<html>
|;

Categories

Resources