{"id":13582528,"url":"https://github.com/fd0/machma","last_synced_at":"2025-04-06T01:11:16.837Z","repository":{"id":45213630,"uuid":"85620094","full_name":"fd0/machma","owner":"fd0","description":"Easy parallel execution of commands with live feedback","archived":false,"fork":false,"pushed_at":"2021-01-02T09:15:17.000Z","size":2479,"stargazers_count":482,"open_issues_count":2,"forks_count":15,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-02-14T22:33:06.077Z","etag":null,"topics":["cli","commands","execution","feedback","go","golang","parallel"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fd0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-20T19:57:42.000Z","updated_at":"2024-01-09T09:42:03.000Z","dependencies_parsed_at":"2022-08-28T16:40:37.808Z","dependency_job_id":null,"html_url":"https://github.com/fd0/machma","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fmachma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fmachma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fmachma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fd0%2Fmachma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fd0","download_url":"https://codeload.github.com/fd0/machma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419861,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","commands","execution","feedback","go","golang","parallel"],"created_at":"2024-08-01T15:02:47.926Z","updated_at":"2025-04-06T01:11:16.820Z","avatar_url":"https://github.com/fd0.png","language":"Go","readme":"[![Status badge for tests](https://github.com/fd0/machma/workflows/Build%20and%20tests/badge.svg)](https://github.com/fd0/machma/actions?query=workflow%3A%22Build+and+tests%22)\n\n# machma - Easy parallel execution of commands with live feedback\n\n## Introduction\n\nIn order to fully utilize modern machines, jobs need to be run in parallel. For\nexample, resizing images sequentially takes a lot of time, whereas working on\nmultiple images in parallel makes much better use of a multi-core CPU and\ntherefore is much faster. This tool makes it very easy to execute tasks in\nparallel and provides live feedback. In case of errors or lines printed by the\nprogram, the messages are tagged with the job name.\n\n`machma` by default reads newline-separated values and replaces all\ncommand-line arguments set to `{}` with the file name. The number of jobs is\nset to the number of cores for the CPU of the host `machma` is running on.\n\n## Sample Usage\n\nResize all images found in the current directory and sub-directories to\n1200x1200 pixel at most:\n\n```shell\n$ find . -iname '*.jpg' | machma --  mogrify -resize 1200x1200 -filter Lanczos {}\n```\n\nThe command specified after the double dash (`--`) is executed with each\nparameter that is set to `{}` replaced with the file name. At the bottom, a few\nstatus lines are printed after a summary line. The lines below visualize the\nstatus of the instances of the program running in parallel. The line for an\ninstance will either contain the name of the file (in this case) that is being\nprocessed followed by the newest message printed by the program.\n\n![demo: resizing files](demos/demo1.gif)\n\n\nPing a large number of hosts, but only run two jobs in parallel:\n\n```shell\n$ cat /tmp/ips | machma -p 2 -- ping -c 2 -q {}\n```\n\nThe program `ping` will exit with an error code when the host is not reachable,\nand `machma` prints an error message for all jobs which returned an error code.\n\n![demo: ping hosts](demos/demo2a.gif)\n\nA slightly more sophisticated (concerning shell magic) example is the\nfollowing, which does the same but recduces the output printed by `ping` a lot:\n\n```shell\n$ cat /tmp/ips | machma -- sh -c 'ping -c 2 -q $0 \u003e /dev/null \u0026\u0026 echo alive' {}\n```\n\n![demo: ping hosts again](demos/demo2b.gif)\n\n\nUsing `--timeout` you can limit the time mogrify is allowed to run per picture. (Prevent jobs from 'locking up')\nThe value for timeout is formatted in golang [time.Duration format](https://golang.org/pkg/time/#Duration).\nWhen the timeout is reached the program gets canceled.\n\n```shell\n$ find . -iname '*.jpg' | machma --timeout 5s --  mogrify -resize 1200x1200 -filter Lanczos {}\n```\n\n### Files With Spaces\n\nSometimes filenames have spaces, which may be problematic with shell commands.\nMost of the time, this should not be a problem at all, since `machma` runs\nprograms directly (using the `execve` syscall on Linux for example) instead of\nusing `system()`. For all other cases there's the `--null` (short: `-0`) option\nwhich instructs `machma` to read items separated by null bytes from stdin. This\ncan be used with the option `-print0` of the `find` command like this:\n\n```shell\n$ find . -iname '*.jpg' -print0 | machma --null --  mogrify -resize 1200x1200 -filter Lanczos {}\n```\n\n## Installation\n\nInstallation is very easy, install a recent version of Go and run:\n\n```shell\n$ go run build.go\n```\n\nAfterwards you can view the online help:\n```shell\n$ ./machma --help\nUsage of ./machma:\n      --no-id              hide the job id in the log\n      --no-name            hide the job name in the log\n      --no-timestamp       hide the time stamp in the log\n  -0, --null               use null bytes as input separator\n  -p, --procs int          number of parallel programs (default 2)\n      --replace string     replace this string in the command to run (default \"{}\")\n      --timeout duration   set maximum runtime per queued job (0s == no limit)\n```\n","funding_links":[],"categories":["Go","CLI Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffd0%2Fmachma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffd0%2Fmachma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffd0%2Fmachma/lists"}