Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Run one service after another service has finished - systemd

UNIX for Beginners Questions & Answers


Tags
systemd, systemd-timer

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-05-2017   -   Original Discussion by guilliber
guilliber guilliber is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 6 October 2017, 3:19 AM EDT
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Run one service after another service has finished - systemd

Hi all
I would like to know how to run task2.service after task1.service has finished.

task1.service has a timer (task1.timer), that makes it run every 5 minutes

Code:
OnCalendar=*:0/5

task2.service is basically a script, that has to work on the files created after task1 has finished.
This is what I have so far:

Code:
# task2.service

[Unit]
Description=Task2
After=network.target

[Service]
Type=oneshot
ExecStart=/media/script.sh
TimeoutStartSec=1min30s

Now, I don't know if I need a timer for task2 too, or if I should include under [Unit]

Code:
Requires=task1.service
After=network.target task1.service

Any help would be appreciated!
Sponsored Links
    #2  
Old Unix and Linux 10-05-2017   -   Original Discussion by guilliber
jgt's Unix or Linux Image
jgt jgt is offline Forum Advisor  
Registered User
 
Join Date: Apr 2007
Last Activity: 22 November 2017, 8:00 AM EST
Location: 44.21.48N 80.50.15W
Posts: 2,002
Thanks: 2
Thanked 272 Times in 255 Posts
why not have task 1 start task 2. just make sure that the previous task2 is complete before starting another task1
Sponsored Links
    #3  
Old Unix and Linux 10-06-2017   -   Original Discussion by guilliber
guilliber guilliber is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 6 October 2017, 3:19 AM EDT
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
I would like to understand the way systemd works and I would like to learn it that way, if it is possible. Thank you.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -4. The time now is 01:40 AM.