Skip to content

Commit d79295c

Browse files
authored
Merge pull request #54 from juzim/add-systemd-info
Added information for creating a system service
2 parents b72db3e + 390a880 commit d79295c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,43 @@ crontab -e
285285
00 09 * * * cd PATH_TO_PROJECT/packtpub-crawler && /usr/bin/python script/spider.py --config config/prod.cfg >> /tmp/packtpub.log 2>&1
286286
```
287287

288+
289+
### Systemd service
290+
Create two files in /etc/systemd/system:
291+
292+
1. packtpub-crawler.service
293+
```
294+
[Unit]
295+
Description=run packtpub-crawler
296+
297+
[Service]
298+
User=USER_THAT_SHOULD_RUN_THE_SCRIPT
299+
ExecStart=/usr/bin/python2.7 PATH_TO_PROJECT/packtpub-crawler/script/spider.py -c config/prod.cfg
300+
301+
[Install]
302+
WantedBy=multi-user.target
303+
```
304+
305+
2. packtpub-crawler.timer
306+
```
307+
[Unit]
308+
Description=Runs packtpub-crawler every day at 7
309+
310+
[Timer]
311+
OnBootSec=10min
312+
OnActiveSec=1s
313+
OnCalendar=*-*-* 07:00:00
314+
Unit=packtpub_crawler.service
315+
Persistent=true
316+
317+
[Install]
318+
WantedBy=multi-user.target
319+
```
320+
321+
Enable the script with ```sudo systemctl enable packtpub_crawler.timer```.
322+
You can test the service with ```sudo systemctl start packtpub_crawler.timer``` and see the output with ```sudo journalctl -u packtpub_crawler.service -f```.
323+
324+
288325
### Newsletter
289326
The script downloads also the free ebooks from the weekly packtpub newsletter.
290327
The [URL](https://goo.gl/kUciut) is generated by a Google Apps Script which parses all the mails.

0 commit comments

Comments
 (0)