How would I know if a Python script executed by a cronjob on a server was actually being executed? :thinking_rotate:
Conversation
Notices
-
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 05:21:44 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 -
Gabe (gabriel@mk.gabe.rocks)'s status on Monday, 18-Sep-2023 05:21:43 JST Gabe @adiz@soc0.outrnat.nl
Have it send you an e-mail or add the time to a log file.
Or have it post to the fediverse so we'll all know it worked!† top dog :pedomustdie: likes this. -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:40 JST Dushman @jeff@misinformation.wikileaks2.org @adiz@soc0.outrnat.nl
I use Alpine on this server :lain_smug3: -
jaf (jeff@misinformation.wikileaks2.org)'s status on Monday, 18-Sep-2023 05:54:41 JST jaf @dushman @adiz the costs of sid snapshots as upstream smh -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:42 JST Dushman @adiz@soc0.outrnat.nl @jeff@misinformation.wikileaks2.org
Ubuntu also uses vixie by default cuz it's a Debian deriv -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 05:54:43 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest Well, I'm using Ubuntu. The Linux distribution for the cultured gentleman. @jeff@misinformation.wikileaks2.org
-
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:44 JST Dushman @jeff@misinformation.wikileaks2.org @adiz@soc0.outrnat.nl
Oh I have replaced the cron daemon on Debian plenty of times because the default (vixie) fucking sucks lol. You just have to make some adjustments and it'll work perfectly fine. -
jaf (jeff@misinformation.wikileaks2.org)'s status on Monday, 18-Sep-2023 05:54:45 JST jaf @dushman @adiz dont fuck with it, it'll break -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:46 JST Dushman @adiz@soc0.outrnat.nl
But yeah this is a certified Debian moment -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 05:54:47 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest That's stability for you! :misato_laugh2:
-
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:48 JST Dushman @adiz@soc0.outrnat.nl
And I do mean crusty. Hasn't been touched since 1999. -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:49 JST Dushman @adiz@soc0.outrnat.nl
Also debian's default cron implementation is crusty as hell so install something like cronie -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 05:54:51 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest Yeah, there should be a cronjob log.
-
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:52 JST Dushman @adiz@soc0.outrnat.nl
Cronjob execution will be logged either way though in the syslog or messages files depending on the system -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 05:54:53 JST Dushman @adiz@soc0.outrnat.nl
Have it log to a file. Very simple to implement. -
† top dog :pedomustdie: (dcc@annihilation.social)'s status on Monday, 18-Sep-2023 05:55:22 JST † top dog :pedomustdie: @dushman @adiz @jeff :slackware: :walter_smug: -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 07:08:40 JST Dushman @adiz@soc0.outrnat.nl @efertone@slippy.xyz @emma@niscii.xyz @jeff@misinformation.wikileaks2.org
Just maintain it and you'll be fine -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 07:08:41 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest I certainly hope this database doesn't become huge. @efertone@slippy.xyz @emma@niscii.xyz @jeff@misinformation.wikileaks2.org
-
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 07:08:42 JST Dushman @adiz@soc0.outrnat.nl @efertone@slippy.xyz @emma@niscii.xyz @jeff@misinformation.wikileaks2.org
Simplest way to do it if you aren't working with a huge database which you won't be on a small instance -
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 07:08:43 JST Dushman @adiz@soc0.outrnat.nl @efertone@slippy.xyz @emma@niscii.xyz @jeff@misinformation.wikileaks2.org #!/bin/sh pg_dump -F c --username dbuser dbname > /path/to/backupdir/whatever-bak`date +%Y-%m-%d`.pgdumpThere, make it run as the postgres user.
-
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 07:08:44 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @efertone@slippy.xyz I really ought look into PostgreSQL scripts or Python scripts for interfacing with PostgreSQL for doing regular database backups and vacuums (although just reading about autovacuum right now, struggling to understand if it's active and configured by default or not). @emma@niscii.xyz @dushman@den.raccoon.quest
-
恵真 :ablobcat_test3: (emma@niscii.xyz)'s status on Monday, 18-Sep-2023 07:08:45 JST 恵真 :ablobcat_test3: @adiz@soc0.outrnat.nl @dushman@den.raccoon.quest when i was setting up my cron thingies i checked the syslog for it its there
-
:ffxivmsq_comp: Efertone :verifiedtrans: (efertone@slippy.xyz)'s status on Monday, 18-Sep-2023 07:08:45 JST :ffxivmsq_comp: Efertone :verifiedtrans: @emma@niscii.xyz @adiz@soc0.outrnat.nl @dushman@den.raccoon.quest I think the easiest one (if you are using systemd, journalctl is one of the best friends):sudo journalctl -u cron | grep "scriptname"
It will show you when they were executed (and what user):# Run by misskey user Sep 17 20:30:01 slippy CRON[389091]: (misskey) CMD (/home/misskey/kiki fetch && /home/misskey/kiki publish) # Run by root (creates daily mysql dumps) Sep 17 01:00:01 slippy CRON[246758]: (root) CMD (/root/backup/backup.database.mysql.sh) # Run by root (creates weekly basebackup for WAL) Sep 17 02:00:01 slippy CRON[252575]: (root) CMD (/root/backup/backup.database.postgresql.sh) # Run by my own user to clean up old remote files through API calls. Sep 17 03:00:01 slippy CRON[258304]: (efertone) CMD (/home/efertone/slippy-maintenance/clean-old-remote-files.py)
It will not record the exist status, but I get an email always when stderr is not empty.
Hope it helps. -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 07:08:46 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest Should be recorded under /var/log/syslog though, right?
-
Dushman (dushman@den.raccoon.quest)'s status on Monday, 18-Sep-2023 07:08:47 JST Dushman @adiz@soc0.outrnat.nl
There is no cronjob specific log by default -
:verified_2:防空識別區𝒔𝒐𝒄𝟶 (adiz@soc0.outrnat.nl)'s status on Monday, 18-Sep-2023 07:09:17 JST :verified_2:防空識別區𝒔𝒐𝒄𝟶 @dushman@den.raccoon.quest Right now I'm mostly just running a script that @efertone@slippy.xyz wrote to delete remote files older than 3 weeks. Beyond that, I think PostgreSQL performs autovacuum by default? I don't know, unsure how to really check and find out. Something more to research/read about when I get some extended downtime on my computer.
Otherwise, I occasionally run VACUUM ANALYZE manually. Might be nice to combine the script you made for pg_dump with one that can perform VACUUM ANALYZE so that the database gets dumped, vacuumed, and analyzed daily + older files get pruned daily + the server reboots daily (right now all my VMs reboot daily). @emma@niscii.xyz @jeff@misinformation.wikileaks2.org
-