Search code examples
linuxupstart

How to copy a file in a upstart script on Linux?


I have a simple upstart job. I want to copy a file there when it is restarted. I can not get it to work. I have read how to execute bash scripts etc from upstart but I dont get it to work. This is what I have tried:

script
    exec bash -c 'cp /opt/test/test.log /opt/test/test.log.old'
end script

When I stop and start the service the file is not copied. Any ideas what I am doing wrong?


Solution

  • This should be run within the pre-start script tag:

    pre-start script
        exec bash -c 'cp /opt/test/test.log /opt/test/test.log.old'
    end script