Automate starting and stopping of programs from terminal

in flag

I have been trying to make it easier and faster to start and stop programs from terminal but didn't get anywhere. Closest thing I found on my searches is this: Starting and stopping of applications but nothing else. I use ubuntu server so no gui at all. In one machine i am running a proxy and I am trying to easy start and stop it without typing long lines, to start it I created a .sh file and I can start it easy enough but once it runs, I have to enter the screen windows where it's running, type Ctrl-C and after few second start it again. Is any way to automate it?

To run it I type this long line:

sudo java -jar myprogram.jar -f /home/franco/operations/proxy/switcher/prx1/setting.conf

I made a script called to start it using screen:

cd /home/franco/operations/startup
su franco -c "screen -dmS prx1 ./"

This works fine and fast to start it but sometimes I need to stop it and restart. Here is where I am failing. I have to get the screen, type ctrl-C and then call my script again to restart.

Is any possibility to make a script to automate it?

I hope I make sense

in flag
Thanks @muru for editing my question
in flag
As I didn't get any suggestion I think my question is silly and there is no way to use kill, pkill or killall without grabbing the PID?

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.