Results 1 to 2 of 2

Thread: Help with QProcess and crontab

  1. #1
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Question Help with QProcess and crontab

    So i'm trying to add content to crontab. So far I've only been able to do it with QProcess("crontab <filename>") but using a temp file is not really optimal for what i'm looking for.

    It's possible to do the same thing in terminal with "echo "* * * * * /command" |crontab -" but so far i haven't been able to do that with qt.

    I'm using Qt 4.7 and the platform for which i'm developing is MeeGo.

    Also, if anyone has any better suggestions for executing tasks that need to be repeated every x minutes/hours/days without the program hogging resources would be appreciated.

  2. #2
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Help with QProcess and crontab

    Incase anyone else needs it, here's the solution.

    Qt Code:
    1. QProcess cronProcess;
    2. QString jobList = "* * * * * /command\n"; // Don't forget \n.
    3. cronProcess.start("crontab", QStringList() << "-");
    4.  
    5. cronProcess.waitForStarted();
    6.  
    7. cronProcess.write(QByteArray(jobList.toAscii()));
    8. cronProcess.closeWriteChannel();
    9.  
    10. cronProcess.waitForFinished();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 0
    Last Post: 26th August 2010, 10:44
  2. QProcess inside QProcess
    By bunjee in forum Qt Programming
    Replies: 7
    Last Post: 4th December 2008, 00:39
  3. QProcess
    By bashamehboob in forum Qt Programming
    Replies: 3
    Last Post: 31st March 2008, 15:21
  4. QProcess cmd
    By Nykoo in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2008, 10:50
  5. Using QProcess..........
    By sar_van81 in forum Qt Programming
    Replies: 7
    Last Post: 12th December 2006, 04:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.