使用wget的CodeIgniter的Cron作业

时间:2015-06-15 21:11:06

标签: php codeigniter cron crontab wget

我很擅长设置cron作业。到目前为止,我已经完成了使用以下脚本每5分钟运行一次:

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if section == 1 {
        // subTaskRow is an array holding all the indexes of the added cells
        // so I know where to add the next one. I also know how many I've added
        return 6 + subTaskRow.count
    } else {
        return super.tableView(tableView, numberOfRowsInSection: section)
    }
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    // If the Sub Task cell is picked
    if (indexPath.section == 1 && indexPath.row == 3) {
        // If this is the first subtask we want it to appear under Sub Tasks
        // We know the index of the cell below sub task so we can add it in directly
        if (subTaskRow.count == 0) {
            subTaskRow.addObject(5)
            tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: 5, inSection: 1)], withRowAnimation: .Automatic)
            tableView.reloadData()
        // Other sub tasks should appear below previous sub tasks
        } else {
            // The last object in sub tasks will always be the
            // indexPath of the previous added cell
            let row = (subTaskRow.lastObject as! Int) + 1
            subTaskRow.addObject(row)
            tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: row, inSection: 1)], withRowAnimation: .Automatic)
            tableView.reloadData()
        }
    }

    tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

// Now we override all the other methods to ensure we don't get a crash
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}

override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}

override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
    return .None
}

override func tableView(tableView: UITableView, indentationLevelForRowAtIndexPath indexPath: NSIndexPath) -> Int {
    return super.tableView(tableView, indentationLevelForRowAtIndexPath: indexPath)
}

当我从命令行运行wget部分时,它完美地运行。但是在crontab中,虽然日志显示它每5分钟运行一次,但没有任何事情发生。我错过了一些容易的事吗?任何帮助表示赞赏!

谢谢!

1 个答案:

答案 0 :(得分:2)

您可以使用

强制使用特定的shell
SHELL=bash
*/5 * etc...

或crontab中的任何内容。然后确保wget在该shell的路径中可用。

否则只需给出一个绝对的/ usr / bin / wget路径。

*/5 * * * * /usr/bin/wget etc...