CYBERTEC Logo

pg_timetable: start-up improvements

07.2020 / Category: / Tags: | |

¡Hola, queridos amigos! We've released several valuable features for pg_timetable in May. It's summer already, and time is flying fast! I hope all of you are well and safe, as well as your families and friends.

Here I want to introduce what's new and how that is useful briefly. If you are unfamiliar with pg_timetable, the best PostgreSQL scheduler in the world, you may read previous posts about it. 😊

--init pg_timetable command-line argument

--init command-line argument, if specified, will force pg_timetable to create the database schema and exit immediately.

During start-up, the database schema is created automatically if absent. Later a worker proceeds into the main loop checking chains and executing tasks.

This behavior is stable, however, mostly unusable in automation scenarios. Usually, you split preparation and work into separate stages. Now you can automate your scripts not only init pg_timetable environment but upgrade it as well. Consider this:

--file pg_timetable command-line argument

That's not all! After schema initialization, one usually wants to add some tasks and chains. Either you are debugging your environment or deploying into production, there are traditionally prepared tasks you want to put into work. In previous versions, one should execute an additional step for that. But we've added --file command-line argument. You can now specify SQL script to be executed, not only during initialization or upgrade, but during an everyday routine.

--no-help pg_timetable command-line argument

If you want more control over output, you may use --no-help command-line argument. The reason might be the same. Pretend you're using pg_timetable in some script, and the only thing you need to know is an exit code. But pg_timetable often tries to provide users with hints about why termination occurred. To suppress help messages, add this command-line argument.

Examples

Usual start

If you start pg_timetable with only parameters needed and a clean database, it will create the necessary schema and proceed into the main loop. Below you can see a typical output. As you can see no tasks available.

Initialize and exit immediately

Create schema if needed and exit returning 0 code. Can be combined with --upgrade argument, if new version of pg_timetable supposed to be run against old schema.

Execute custom SQL script at the start

You may specify arbitrary SQL script to execute during start-up. But beware you are not duplicating tasks in case of a working system. Here I will add sample chain and pg_timetable will execute it in the main loop when the time has come.

The same example on existing schema adding some interval chains. As you can see, no schema is created this time, but the custom script is executed either way.

Backup and clean log before upgrade

Suppose we want to upgrade pg_timetable version, but with that we want clean logs for the new version. In this case, one may start it in --upgrade mode, provide special actions to be done with --file="backup_logs.sql" and specify --init to exit immediately after upgrade.

Suppress help message, but leave error output

Further reading

If you want to know about every improvement and a bug fix in the previous version, please, check our repository Release page.

And do not forget to Star it, Watch it and maybe even Fork it. Why not? We are Open Source after all!

Stay safe! Love! Peace! Elephant! ❤🕊🐘

0 0 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Claudio Oliveira
Claudio Oliveira
3 years ago

Obrigado pelo seu grande trabalho.

Pavlo Golub
Pavlo Golub
3 years ago

Obrigado pelo vosso apoio!

CYBERTEC Logo white
CYBERTEC PostgreSQL International GmbH
Römerstraße 19
2752 Wöllersdorf
Austria

+43 (0) 2622 93022-0
office@cybertec.at

Get the newest PostgreSQL Info & Tools


    This site is protected by reCAPTCHA and the Google Privacy Policy & Terms of Service apply.

    ©
    2024
    CYBERTEC PostgreSQL International GmbH
    phone-handsetmagnifiercrosscross-circle
    2
    0
    Would love your thoughts, please comment.x
    ()
    x
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram