Script to synch, then shutdown?

I would like a script that would cause my Dropbox and Mega cloud folders to synch with the cloud, then shut down. The best I’ve come up with is

   #!/bin/bash
   megasync
   dropbox start -i
   shutdown

This starts my cloud software, which usually synchs the minute it is started. I wonder if they’d start some background stuff that send the computer into a loop before shutdown. Anyone know? have suggestions?

I’m running Linux Mint 2.1 Cinnamon on a desktop and a laptop. TIA.

Cecilieaux

What exactly is your issue? Does it never shut down?

Please explain as detailed as possible. Thank you.

I haven’t tried the script. I’m very new at scripting and I’m nervous. Should I try it? Does it look like it might work?

Cecilieaux

Run up a VM and try the script for a couple of files to sync if you don’t want to affect your main machine, always a safer way to do something you’re not sure about.

To me, it looks simple and sensible enough. If I were you, I’d just try it.

Some configurations require shutdown to be executed by root and usually you provide it with command line parameters like shutdown -h now.

An equivalent would also be poweroff

In my MATE I’d use
mate-session-save --shutdown-dialog
This causes a normal shutdown, just like I had press shutdown button.
I believe the Cinnamon equivalent would be:
cinnamon-session-quit --power-off

These don’t require root rights.

OK, tried it. Megasync wouldn’t turn off by itself and the shutdown hung until I clicked it shut. So, I did this:

#!/bin/bash
megasync
dropbox start -i
time -300 -p
dropbox stop
killall -9 megasync
cinnamon-session-quit --power-off

Anyone see any red flags?

Yes, kill -9 is literally killing the process and one should do that only in emergencies. If you regularly shutdown something, you should do that as gracefully as possible.

Well, it worked fine for me. I may have to play with the pause time.