Just want to know how can i run a .command file in background during macOS log in without terminal being opened. i have a rclone_mount.command file which would run the mount command by opening terminal and not in bg. Is what im trying to achieve possible? Used automator to run shell script but rclone command not found error.
My mount command:
rclone mount --daemon --allow-other --vfs-read-chunk-size 32M --vfs-cache-max-size 10G --poll-interval 15m --vfs-cache-mode full --tpslimit 10 --tpslimit-burst 0 --cache-dir /Users/ishaanrathod/rclone/cache --disable About GDrive: /Users/ishaanrathod/rclone/GDrive
while executing "sudo launchctl load -w /Library/LaunchDaemons/com.gdrive.plist", i get the error:
Load failed: 5: Input/output error
Try running launchctl bootstrap as root for richer errors.
alright i tried to fix it through launch control, complicated but i fixed it, but still gives the SAME error and launch control aint giving me any more suggestions, will try shortcuts
For rclone mount I would also use user daemon instead of system daemon. So job plist would be in ~/Library/LaunchDaemons instead of /Library/LaunchDaemons. This way you run it as your user and not root.
I have not working example at the moment with me but hopefully now you have enough info to experiment and make it work:) I did in the past many times - it requires a bit of reading but as soon as you grasp overall concept it is easy.
If you are familiar with Linux then launchd is equivalent of systemd
tried this and ran without sudo, basically "launchctl load -w ~/Library/LaunchAgents/com.gdrive.plist", works.
but while running "launchctl start -w ~/Library/LaunchAgents/com.gdrive.plist", error:
Job returned error code 1
Unfortunately there is no way of knowing what this code
means, as a programmer can choose arbitrary exit codes
if he wants. Maybe the user manual of the program
contains a list of all exit codes with an explanation.
Otherwise ask the author about the meaning of the error
code.
If you are lucky the program uses standard exit codes. In
this case the description could be:
errno.h: Operation not permitted. An attempt was made
to perform an operation limited to processes with
appropriate privileges or to the owner of a file or other
resources.
got shortcuts working but i dont know what it is exactly. Like the "localhost" is mounted instead of "fuse-t" and i do not know if it follows these arguments:
rclone mount --daemon --allow-other --vfs-read-chunk-size 32M --vfs-cache-max-size 10G --poll-interval 15m --vfs-cache-mode full --tpslimit 10 --tpslimit-burst 0 --cache-dir /Users/ishaanrathod/rclone/cache --disable About GDrive: /Users/ishaanrathod/rclone/GDrive
because i didnt insert it anywhere nor does it ask for it
These are only examples. You have to adapt them to your needs.
It looks like they run rclone serve webdav and mount locally so not exactly rclone mount
The reason I sent them is to show you how to run rclone commands in shortcuts. Also it was first hit on google:) You can try more research - maybe there are better examples.
haha yes was just going to comment this way. Just paste your mount command in a shell script in shortcuts, add it to dock, open at login, remove from dock (saves as application in launchpad) and DONE, works like a charm. Thank you so much!
Most likely network is not ready at very early login sequence. Maybe DNS service no ready yet etc.
Proper solution would be to add network detection logic to mounting sctipt and e.g. wait until network is working or abandoning if not in specified time. But I have no time now for any complex solutions:)
Dirty and easy is just to add sleep 30 before your mount command. I think it does not require explanation.
sleep 30; rclone mount....
Time is in seconds - so you can experiment what works for you.
Let me know if it works - I will add it to the guide:) Or add yourself as a comment.