I want very specific a cronjob every 24 minutes.
By doing:
*/24 * * * * /usr/bin/php /test.php
Would this cron run every 0, 24, 48, 12, 36, 0 minutes or just 0, 24, 48?
If it only runs on 0, 24, 48 minutes, what would be the good one to run a cronjob every 0, 24, 48, 12, 36, 0 minutes?
It would run at 0, 24, and 48 minutes after the hour.
Since 24 minutes is exactly 1/5 of 2 hours, you can use two entries to run a job every 24 minutes:
*/24 */2 * * * /usr/bin/php /test.php
12-36/24 1-23/2 * * * /usr/bin/php /test.php
or perhaps more simply:
0,24,48 */2 * * * /usr/bin/php /test.php
12,36 1-23/2 * * * /usr/bin/php /test.php
(Incidentally, putting your test.php script in the root directory is an odd choice.)
Related
Why does PyCharm suddenly wants to start a test?
My script is named 1_selection_sort.py And I'm trying to call the function test_selection_sort, and I'm just running with <current file> (Added in 2022.2.2 I assume).
I'm pretty sure this worked 24/10/2022 (Version 2022.2.2 and maybe 2022.2.3, but in 2022.2.4 it's no longer working).
Could someone please tell me when and why this was changed? Or maybe I did something wrong during installing?
My file is NOT named according to this naming scheme (https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#conventions-for-python-test-discovery):
In those directories, search for test_*.py
or *_test.py files, imported by their test
package name.
"""
Schrijf een functie selection_sort dat een lijst in dalende volgorde sorteert m.b.v. selection sort.
"""
def selection_sort(lijst):
for i in range(len(lijst)):
for j, number in enumerate(lijst):
if number < lijst[i]:
lijst[j] = lijst[i]
lijst[i] = number
return lijst
def test_selection_sort(lijst, check):
print(lijst)
result = selection_sort(lijst)
print(result)
print(check)
assert result == check
print("Begin controle selection_sort")
test_selection_sort([1, 3, 45, 32, 65, 34], [65, 45, 34, 32, 3, 1])
test_selection_sort([1], [1])
test_selection_sort([54, 29, 12, 92, 2, 100], [100, 92, 54, 29, 12, 2])
test_selection_sort([], [])
print("Controle selection_sort succesvol")
Output:
"C:\Program Files\Anaconda3\python.exe" "C:/Users/r0944584/AppData/Local/JetBrains/PyCharm Community Edition 2022.2.4/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" --path "C:\Users\r0944584\Downloads\skeletons(4)\skeletons\1_selection_sort.py"
Testing started at 14:13 ...
Launching pytest with arguments C:\Users\r0944584\Downloads\skeletons(4)\skeletons\1_selection_sort.py --no-header --no-summary -q in C:\Users\r0944584\Downloads\skeletons(4)\skeletons
============================= test session starts =============================
collecting ... collected 1 item
1_selection_sort.py::test_selection_sort ERROR [100%]
test setup failed
file C:\Users\r0944584\Downloads\skeletons(4)\skeletons\1_selection_sort.py, line 15
def test_selection_sort(lijst, check):
E fixture 'lijst' not found
> available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
C:\Users\r0944584\Downloads\skeletons(4)\skeletons\1_selection_sort.py:15
========================= 1 warning, 1 error in 0.01s =========================
Process finished with exit code 1
The solution I found was to disable Pytest following this answer: https://stackoverflow.com/a/59203776/13454049
Disable Pytest for you project
Open the Settings/Preferences | Tools | Python Integrated Tools settings dialog as described in Choosing Your Testing Framework.
In the Default test runner field select Unittests.
Click OK to save the settings.
I have a 500k line excel like the sample below:
ref, RSRQ, Signal, SNR, TestDate
ST782347, -13, -116, 40, 01/04/2020
ST782347, -9, -111, 110, 22/02/2020
ST782347, -10, -115, 70, 22/02/2020
ST782347, -9, -111, 110, 22/02/2020
ST782349, -10, -110, 90, 22/02/2020
ST782349, -10, -114, 50, 22/02/2020
Now the "ref" can have 1 to 800 equal values, but I only want the most recent 10 if it has 10 or more, otherwise should be discarded. I have been stuck here for a couple of days now, any help will be extremely appreciated.
I am assuming that you want to do this process once only?
order by date, the most recent up (you should be able to use the filter on this,
maybe your data is already ordered?)
run a count on ref
mark and filter results below 10
see image for steps 2 and 3
Hope this helps!
PS: always helps to give a sample of your data in Excel format, so that we don't have to reproduce it... cheers
I get dates on the site for some events:
>>> parse(event.find_element_by_xpath('../td[#data-dt]').get_attribute('data-dt'))
datetime.datetime(2019, 11, 26, 19, 15, tzinfo=<StaticTzInfo 'Z'>)
How can I convert this time to a local time zone, so that I can count down to the start of the event?
I found a solution:
from tzlocal import get_localzone
parse(event.find_element_by_xpath('../td[#data-dt]').get_attribute('data-dt')).astimezone(get_localzone())
When running
>>> a = np.linspace(0, 330, 330, 1, dtype=int)
>>> print(a)
[ 0, 1, 2, ..[skipped for readability].. 323, 324, 325, 326, 327, 328, 330])], dtype=int
I expect the second last number to be 329 instead of 328. Why is this not the case? It's probably because that number in a float will be 328.99696049 but I do wonder how I can include it into my output, and if it does matter for my data purity when I do calculations on that number.
Yes, your assumption is correct. np.linspace distributes 330 values between 0 and 330 which means the stepsize between two neighboring values is (end - start) / (steps - 1) = 330 / 329. Since you coerce to int, the decimal part is truncated.
If you would like a stepsize of 1 continously, you need 331 steps:
a = np.linspace(0, 330, 331, 1, dtype=int)
Of course it's even simpler to get the same result using np.arange:
a = np.arange(331)
My requirement is that I would like to stop the poller after a fixed interval of time say 9 (hrs.). For now I am trying to stop the poller after 1 min. Following is my code:
<int-task:scheduler id="scheduler" pool-size="10"/>
<int-task:scheduled-tasks scheduler="scheduler">
<int-task:scheduled ref="incomingFiles.adapter" method="stop" fixed-delay="#{10 * 1000}"/>
</int-task:scheduled-tasks>
But now what I observe is that when I start my program then on startup I immediately get the message in the console as:
> INFO: Starting beans in phase 0 May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started incomingFiles.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding {service-activator} as a
> subscriber to the 'incomingFiles' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext#f4d5bc9.incomingFiles'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started
> org.springframework.integration.config.ConsumerEndpointFactoryBean#0
> May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding {router} as a subscriber to
> the 'contextStartedEventChannelChannel' channel May 28, 2014 10:27:55
> AM org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext#f4d5bc9.contextStartedEventChannelChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started
> org.springframework.integration.config.ConsumerEndpointFactoryBean#1
> May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {outbound-channel-adapter:trueChannel.adapter} as a subscriber to the
> 'trueChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext#f4d5bc9.trueChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started trueChannel.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {outbound-channel-adapter:falseChannel.adapter} as a subscriber to the
> 'falseChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext#f4d5bc9.falseChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started falseChannel.adapter May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.EventDrivenConsumer
> logComponentSubscriptionEvent INFO: Adding
> {logging-channel-adapter:_org.springframework.integration.errorLogger}
> as a subscriber to the 'errorChannel' channel May 28, 2014 10:27:55 AM
> org.springframework.integration.channel.AbstractSubscribableChannel
> adjustCounterIfNecessary INFO: Channel
> 'org.springframework.context.support.ClassPathXmlApplicationContext#f4d5bc9.errorChannel'
> has 1 subscriber(s). May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint start INFO:
> started _org.springframework.integration.errorLogger May 28, 2014
> 10:27:55 AM
> org.springframework.integration.file.FileReadingMessageSource receive
> INFO: Created message: [[Payload File
> content=C:\TEMP\incomingFile\ETD.CONFIRM.60326.140519.T0613170][Headers={id=b003893a-e013-57c8-0c96-55db627ec643, timestamp=1401287275402}]] May 28, 2014 10:27:55 AM
> org.springframework.integration.endpoint.AbstractEndpoint stop INFO:
> stopped incomingFiles.adapter
Somewhere in the start of the starttup logs we get:
May 28, 2014 10:27:55 AM
org.springframework.integration.endpoint.AbstractE ndpoint start INFO:
started incomingFiles.adapter
Somewhere in the end of the startup logs we get:
May 28, 2014 10:27:55 AM
org.springframework.integration.endpoint.AbstractE ndpoint stop INFO:
stopped incomingFiles.adapter
Why the incomingFiles.adapter has been stopped immediately while our fixed-delay="#{10 * 1000}" is 10 sec. Time is exactly same and there is absolutely no delay. So ideally the poller should stop after 10 sec. and not immediately. Also there are 4 files in the directory and its picking up only one.
Please do suggest what's wrong.
Well, I see. The
<int-task:scheduled ref="incomingFiles.adapter" method="stop"
fixed-delay="#{10 * 1000}"/>
produces PeriodicTrigger which result (nextExecutionTime) depends on triggerContext.lastScheduledExecutionTime() and if it is null (your case) it invokes underlying method immidiatelly.
Let's try this!
<task:scheduled ref="incomingFiles.adapter" method="stop"
fixed-delay="#{10 * 1000}" initial-delay="#{10 * 1000}"/>
I mean the same value for the initial-delay to postpone the first stop task for the desired time.