I have many python script that run in schedule (its crawlers). currently i'm using tmux to automate the script running in my ec2 instance. but since the number of scripts are growing, its getting consume much RAM. is there any solution for this kind of problem ? or architecture ?
1 Answer
A possibility could be to use the batch(1) or at(1) (or prehaps crontab(1)) Linux commands (to run your Python scripts in sequence).
Another possibility might be to recode the slow and CPU intensive Python scripts using some practically faster programming language (like Ocaml or Rust or C++ -compiled by GCC- or SBCL).
You could even consider using program generating scripts. Maybe RefPerSys could be relevant.
5 Comments
pambudi
do you mean I just need 1 tmux window (currently i used around 20 window to run all of those scripts), and set the scheduller by using linux at instead ? so its reduce the tmux consume of ram memory ?
Basile Starynkevitch
Read tutorials and documentations of these commands. Explain in your question why you have to use tmux and what your scripts are doing
pambudi
im aiming to run python script regularly e.g (every week, every 3 days) with lowest ram memory usage. but I think for my use case, crontab will be the good choice. thanks for the insight. btw, is there's any technology that has functionality like crontab but its has better performance or more modern ?
Basile Starynkevitch
Explain in your question why
crontab or at or batch has bad peformance. Explain also what kind of python scripts are you running, and why can't you recode (in some practically faster language like Ocaml [on ocaml.org/] or C++ (with gcc.gnu.org ....) or Rust or Go or Common Lisp with sbcl.org ) those scripts that are CPU intensive. Explain why you need something more modern, and your definition of modern software.pambudi
1. I haven't test crontab or at or batch before. its just my assumption. that assumption coming from my thought that : a. TMUX case : I execute python script (that has scheduler code) one time. then the script will idle if not in schedule to run. this is takes ram memory b. crontab or cronjob : the kernel execute it it when only in schedule. no idle. so the script totally shutdown 2. I don't say crontab or at or batch has bad performance. CMIIW