LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script for closing and starting Evolution Mail? (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-for-closing-and-starting-evolution-mail-4175448153/)

pommeldier 02-01-2013 07:22 AM

Shell script for closing and starting Evolution Mail?
 
Hello,

I've been looking for shell script that closes Evolution and eventually starts it again so I can clear the e-mails in custom made folder with a crontab command. But i can't quite find one, neither that i have an idea how to make one. I'm new to Ubuntu.

Or if they're is a better way to do this then i'm pleased to hear it.

Thanks,

Pommeldier.

rtmistler 02-01-2013 09:00 AM

Try using pkill(1).

One of the most common script types to use is bash. Here are some references to get you going:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://tldp.org/LDP/abs/html/
http://floppix.ccai.com/scripts1.html

The simplest script here would be:

Code:

#!/bin/bash
# script to kill evolution, run my cron, and then re-run evolution

pkill -signal 9 evolution
(run your cron command here)
evolution &;


unSpawn 02-01-2013 09:48 AM

Quote:

Originally Posted by rtmistler (Post 4882294)
Try using pkill(1).

Its manual or info pages or documentation should confirm that but IIGC Evolution has a switch to force closing it down. Since it has one it's probably more graceful. If you need to use 'pkill' then the suggested way is to use a -15 first, (u)sleep a bit and then -9.


Quote:

Originally Posted by pommeldier (Post 4882210)
clear the e-mails in custom made folder

How or what with does Evolution populate this "custom made folder"? Is its source a remote IMAP or POP3 account? Or a local filter or search result? I'm not saying it has (I don't use it), but Evolution is a matured product so it may have scripts or plug-ins, or maybe expose its API in other ways, to accomplish what you want. And even if it doesn't have anything useful it may be an interesting suggestion for developers to look into...

pommeldier 02-04-2013 05:47 AM

Quote:

Originally Posted by unSpawn (Post 4882330)
Its manual or info pages or documentation should confirm that but IIGC Evolution has a switch to force closing it down. Since it has one it's probably more graceful. If you need to use 'pkill' then the suggested way is to use a -15 first, (u)sleep a bit and then -9.

Do i just put the -15 infront of the -signal 9?



Quote:

Originally Posted by unSpawn (Post 4882330)
How or what with does Evolution populate this "custom made folder"? Is its source a remote IMAP or POP3 account? Or a local filter or search result? I'm not saying it has (I don't use it), but Evolution is a matured product so it may have scripts or plug-ins, or maybe expose its API in other ways, to accomplish what you want. And even if it doesn't have anything useful it may be an interesting suggestion for developers to look into...

Im using a POP3 account.

unSpawn 02-04-2013 06:45 AM

Quote:

Originally Posted by pommeldier (Post 4884020)
Do i just put the -15 infront of the -signal 9?

Try something like 'pkill -TERM [something]; sleep 3s; pkill -KILL [something];'.


Quote:

Originally Posted by pommeldier (Post 4884020)
Im using a POP3 account.

OK, but how or what with does Evolution populate this "custom made folder"? It's not a "plain" view of a POP3 mail box isn't it? Is it a local message filter or search result or something?

pommeldier 02-04-2013 07:50 AM

Quote:

Originally Posted by unSpawn (Post 4884045)
OK, but how or what with does Evolution populate this "custom made folder"? It's not a "plain" view of a POP3 mail box isn't it? Is it a local message filter or search result or something?

Ill explain the use of this folder. It's just a folder that filters e-mails with certain e-mail adresses and puts them in this folder. Does this answer your question?

unSpawn 02-04-2013 08:46 AM

I don't like guessing but I'd say it's like a "virtual folder" (as in http://library.gnome.org/users/evolu...olders.html.en), and editing the search conditions should update its contents (or see if Ctrl+E works). Else, like I said before, it may be something for the developers to look into. Check http://bugzilla.gnome.org/ for related open tickets and workarounds and else create your own suggestion or bug report?

pommeldier 02-04-2013 09:19 AM

I guess it is a virtual folder. But anyway. I solved the half of my problem. I made 3 different bash scripts with one that kills, clears and starts.
But now i clear the mbox file of the subfolder and it shows 0 bytes. But in the folder when i start evolution. The mails are not gone.

Any idea how i could delete them?

jpollard 02-04-2013 10:11 AM

You risk serious mail corruption by aborting evolution with a -9. It could be in the middle of updating an index and killing that could leave the index in an unknown state.

Rupadhya 02-04-2013 11:17 AM

I have been doing the following in my backup script.
Code:

echo Evolution Backup Started `date` >> $RajHome/backup.log
# shutdown evolution, so we get a good backup
/usr/bin/gconftool-2 --shutdown >/dev/null
/usr/bin/evolution --force-shutdown >/dev/null

This seems to shutdown Evolution nicely..

- Raj

pommeldier 02-07-2013 06:37 AM

I solved it my problem with this:

pkill Evolution
03 * * * * > /blablabla/thefile
evolution &

I used a different Bash script for every single line. Because for some reason it doesn't work if i put it in a single script.
And i added the 3 scripts to crontab.

jpollard 02-07-2013 06:57 AM

pkill is not necessarily a graceful shutdown. could be, if it is caught and appropriately handled.

unSpawn 02-07-2013 08:02 AM

Like I hinted at already in post #3 Evolution itself has a switch to force closing it down. Such a switch would not exist if the developers meant it in the Sledge Hammer "Trust me, I know what I'm doing." kind of way.


All times are GMT -5. The time now is 05:29 AM.