diff --git a/Procedures,-event-hooks-and-cronjobs-as-Python-scripts.md b/Procedures,-event-hooks-and-cronjobs-as-Python-scripts.md index ef3a750..9cc2e99 100644 --- a/Procedures,-event-hooks-and-cronjobs-as-Python-scripts.md +++ b/Procedures,-event-hooks-and-cronjobs-as-Python-scripts.md @@ -51,4 +51,21 @@ from platypush.message.event.assistant import SpeechRecognizedEvent @hook(SpeechRecognizedEvent) def test_procedure(event, **content): print('Recognized speech: {}'.format(event.args['phrase'])) +``` +As well as cronjobs: + +```python +# ~/.config/platypush/scripts/test.py + +from platypush.cron import cron +from platypush.utils import run + +# Run it every minute +@cron('* * * * *') +def test_cron(event, **content): + import os + import datetime + + with open(os.path.expanduser('~/test.txt'), 'a') as f: + f.write('The time is: {}\n'.format(datetime.datetime.now().isoformat())) ``` \ No newline at end of file