Script to capture and send data to PC

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I need to write a script to automate the process of capturing and sending data.



I have the script mqtt.py(on my Raspberry Pi) which constantly captures and stores data in myFile.dat.
I use the rsync command to send the file from my Raspberry Pi to my pc.



I need to run the mqtt.py script to start capturing data and lets say after 1 minute, the process stops and the file is sent to my pc and afterwards the capturing process is launched again and after 1 min same thing again.



I tried to write the script and i am missing the command to kill the process mqtt.py.



while(true) do

python mqtt.py #Capturing and storing data in myFile.dat
echo "Process mqtt.py started"

sleep 60 #After 1 minute

#Command to kill process mqtt.py

echo "Process mqtt.py stopped"

#Sending myFile.dat to PC
rsync -avz --remove-source-files myFile.dat chb-pc@192.168.100.7:/home/chb-pc/Desktop/ftp
echo "File sent to destination"

done









share|improve this question
























  • pkill mqtt.py should be enough.

    – Rui F Ribeiro
    Jan 27 at 13:15












  • For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

    – Bhavish S Dussoye
    Jan 28 at 10:55















0















I need to write a script to automate the process of capturing and sending data.



I have the script mqtt.py(on my Raspberry Pi) which constantly captures and stores data in myFile.dat.
I use the rsync command to send the file from my Raspberry Pi to my pc.



I need to run the mqtt.py script to start capturing data and lets say after 1 minute, the process stops and the file is sent to my pc and afterwards the capturing process is launched again and after 1 min same thing again.



I tried to write the script and i am missing the command to kill the process mqtt.py.



while(true) do

python mqtt.py #Capturing and storing data in myFile.dat
echo "Process mqtt.py started"

sleep 60 #After 1 minute

#Command to kill process mqtt.py

echo "Process mqtt.py stopped"

#Sending myFile.dat to PC
rsync -avz --remove-source-files myFile.dat chb-pc@192.168.100.7:/home/chb-pc/Desktop/ftp
echo "File sent to destination"

done









share|improve this question
























  • pkill mqtt.py should be enough.

    – Rui F Ribeiro
    Jan 27 at 13:15












  • For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

    – Bhavish S Dussoye
    Jan 28 at 10:55













0












0








0








I need to write a script to automate the process of capturing and sending data.



I have the script mqtt.py(on my Raspberry Pi) which constantly captures and stores data in myFile.dat.
I use the rsync command to send the file from my Raspberry Pi to my pc.



I need to run the mqtt.py script to start capturing data and lets say after 1 minute, the process stops and the file is sent to my pc and afterwards the capturing process is launched again and after 1 min same thing again.



I tried to write the script and i am missing the command to kill the process mqtt.py.



while(true) do

python mqtt.py #Capturing and storing data in myFile.dat
echo "Process mqtt.py started"

sleep 60 #After 1 minute

#Command to kill process mqtt.py

echo "Process mqtt.py stopped"

#Sending myFile.dat to PC
rsync -avz --remove-source-files myFile.dat chb-pc@192.168.100.7:/home/chb-pc/Desktop/ftp
echo "File sent to destination"

done









share|improve this question
















I need to write a script to automate the process of capturing and sending data.



I have the script mqtt.py(on my Raspberry Pi) which constantly captures and stores data in myFile.dat.
I use the rsync command to send the file from my Raspberry Pi to my pc.



I need to run the mqtt.py script to start capturing data and lets say after 1 minute, the process stops and the file is sent to my pc and afterwards the capturing process is launched again and after 1 min same thing again.



I tried to write the script and i am missing the command to kill the process mqtt.py.



while(true) do

python mqtt.py #Capturing and storing data in myFile.dat
echo "Process mqtt.py started"

sleep 60 #After 1 minute

#Command to kill process mqtt.py

echo "Process mqtt.py stopped"

#Sending myFile.dat to PC
rsync -avz --remove-source-files myFile.dat chb-pc@192.168.100.7:/home/chb-pc/Desktop/ftp
echo "File sent to destination"

done






shell-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 27 at 13:14









Rui F Ribeiro

40.2k1479135




40.2k1479135










asked Jan 27 at 13:12









Bhavish S DussoyeBhavish S Dussoye

31




31












  • pkill mqtt.py should be enough.

    – Rui F Ribeiro
    Jan 27 at 13:15












  • For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

    – Bhavish S Dussoye
    Jan 28 at 10:55

















  • pkill mqtt.py should be enough.

    – Rui F Ribeiro
    Jan 27 at 13:15












  • For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

    – Bhavish S Dussoye
    Jan 28 at 10:55
















pkill mqtt.py should be enough.

– Rui F Ribeiro
Jan 27 at 13:15






pkill mqtt.py should be enough.

– Rui F Ribeiro
Jan 27 at 13:15














For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

– Bhavish S Dussoye
Jan 28 at 10:55





For some reasons it did not work. I found another alternative to end the process after 60 seconds by adding some lines in my python program. Thank you for the suggestion.

– Bhavish S Dussoye
Jan 28 at 10:55










1 Answer
1






active

oldest

votes


















0














Since you have a time-based requirement, I would suggest using timeout as an alternative:



timeout 60 python mqtt.py


timeout will start the command (python mqtt.py) and wait for the specified duration (60 seconds in this case). If the command is still running after that, a signal will be sent to the command to terminate it. The default signal is SIGTERM, but you can specify an alternate signal. You can also send a secondary SIGKILL signal to ensure that the program is actually killed.



The manual for timeout can be found here.






share|improve this answer























  • That helped me. thank you

    – Bhavish S Dussoye
    Jan 28 at 10:54











  • @BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

    – Haxiel
    Jan 28 at 10:59










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497013%2fscript-to-capture-and-send-data-to-pc%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Since you have a time-based requirement, I would suggest using timeout as an alternative:



timeout 60 python mqtt.py


timeout will start the command (python mqtt.py) and wait for the specified duration (60 seconds in this case). If the command is still running after that, a signal will be sent to the command to terminate it. The default signal is SIGTERM, but you can specify an alternate signal. You can also send a secondary SIGKILL signal to ensure that the program is actually killed.



The manual for timeout can be found here.






share|improve this answer























  • That helped me. thank you

    – Bhavish S Dussoye
    Jan 28 at 10:54











  • @BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

    – Haxiel
    Jan 28 at 10:59















0














Since you have a time-based requirement, I would suggest using timeout as an alternative:



timeout 60 python mqtt.py


timeout will start the command (python mqtt.py) and wait for the specified duration (60 seconds in this case). If the command is still running after that, a signal will be sent to the command to terminate it. The default signal is SIGTERM, but you can specify an alternate signal. You can also send a secondary SIGKILL signal to ensure that the program is actually killed.



The manual for timeout can be found here.






share|improve this answer























  • That helped me. thank you

    – Bhavish S Dussoye
    Jan 28 at 10:54











  • @BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

    – Haxiel
    Jan 28 at 10:59













0












0








0







Since you have a time-based requirement, I would suggest using timeout as an alternative:



timeout 60 python mqtt.py


timeout will start the command (python mqtt.py) and wait for the specified duration (60 seconds in this case). If the command is still running after that, a signal will be sent to the command to terminate it. The default signal is SIGTERM, but you can specify an alternate signal. You can also send a secondary SIGKILL signal to ensure that the program is actually killed.



The manual for timeout can be found here.






share|improve this answer













Since you have a time-based requirement, I would suggest using timeout as an alternative:



timeout 60 python mqtt.py


timeout will start the command (python mqtt.py) and wait for the specified duration (60 seconds in this case). If the command is still running after that, a signal will be sent to the command to terminate it. The default signal is SIGTERM, but you can specify an alternate signal. You can also send a secondary SIGKILL signal to ensure that the program is actually killed.



The manual for timeout can be found here.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 27 at 15:25









HaxielHaxiel

2,6951914




2,6951914












  • That helped me. thank you

    – Bhavish S Dussoye
    Jan 28 at 10:54











  • @BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

    – Haxiel
    Jan 28 at 10:59

















  • That helped me. thank you

    – Bhavish S Dussoye
    Jan 28 at 10:54











  • @BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

    – Haxiel
    Jan 28 at 10:59
















That helped me. thank you

– Bhavish S Dussoye
Jan 28 at 10:54





That helped me. thank you

– Bhavish S Dussoye
Jan 28 at 10:54













@BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

– Haxiel
Jan 28 at 10:59





@BhavishSDussoye That's great :-). If my answer has resolved your problem completely, you may mark it as accepted by clicking the 'tick' mark next to it. This grants reputation to both of us.

– Haxiel
Jan 28 at 10:59

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497013%2fscript-to-capture-and-send-data-to-pc%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?